mysql-5.1.72的安装配置过程(mysql8.0安装及配置超详细教程)
admin2024-08-14 10:16:05Linux运维
Mysql-5.1.72的安装配置过程
1.groupadd mysql
useradd -g mysql -s /sbin/nologin -M mysql
id mysql #查看mysql是否创建成功
cd /home/shnne/tools/
下载mysql-5.1.72
tar xf mysql-5.1.72.tar.gz #解压
cd mysql-5.1.72
2.编译
./configure \
--prefix=/application/mysql5.1.72 \
--with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock \
--localstatedir=/application/mysql5.1.72/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--with-extra-charsets=complex \
--with-readline \
--with-ssl \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static
编译过程中可能湖iyou以下报错
checking for termcap functions library... configure: error: No curses/termcap library found
解决办法 yum -y install ncurses-devel
在重新编译
make
可能还会出现报错
../depcomp: line 512: exec: g++: not found
解决办法:
安装yum -y install gcc-c++
安装完成之后再次编译make
可能会出现如下错误:
make[2]: *** [my_new.o] Error 1
是因为gcc-c++是在configure之后安装的,此时只需重新configure后再编译make即可
make && make install
3.安装完毕
echo $?
ln -s /application/mysql5.1.72/ /application/mysql
ll /application/mysql
cd /home/shnne/tools/mysql-5.1.72/support-files
cp my-small.cnf /etc/my.cnf
创建存放数据文件的地方
mkdir /application/mysql/data -p
chown -R mysql.mysql /application/mysql
ll !$
初始化数据库
/application/mysql/bin/mysql_install_db --basedir=/application//mysql --datadir=/application/mysql/data/ --user=mysql
出现以下两个OK就说明可以了
Installing MySQL system tables...
170928 17:24:54 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
170928 17:24:54 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/application//mysql/bin/mysqladmin -u root password 'new-password'
/application//mysql/bin/mysqladmin -u root -h study password 'new-password'
Alternatively you can run:
/application//mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /application//mysql ; /application//mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /application//mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /application//mysql/scripts/mysqlbug script!
cd /home/shnne/tools/mysql-5.1.72/support-files
cp my-small.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld
添加(大概46行)
basedir=/application/mysql/
datadir=/application/mysql/data/
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
在检查端口和服务
ps -ef|grep mysqld
netstat -antup|grep mysqld
lsof -i :3306
启动的另外一种方法
启动
/application//mysql/bin/mysqld_safe &
关闭
mysqladmin shutdown
不要上面的方法混用,容易出问题
一些mysql的用法
登陆mysql 默认是没有密码的
/application/mysql/bin/mysql
mysql> show databases;
mysql> select version();
mysql> select user();
mysql> drop database test; #删除默认的test数据库
mysql> select user,host from mysql.user; #查询msyql数据库里的user表里的登陆用户
mysql> drop user ""@study; #删除用户为空的 user@host
mysql> update mysql.user set host='shnne' where host='study' and user='root'; #熟悉命令用
mysql> updata mysql.user set password=Password('123456') where user='root' and host='shnne';
mysql> delete from mysql.user where user='' and host='study';#sql语句删除
mysql> grant all on *.* to shnne@'localhost' identified by '123'; #创建用户授权
mysql> flush privileges;