linux安装MySQL5.7 tar.gz

系统: CentOS6.9

 

1、下载mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

 

linux安装MySQL5.7 tar.gz_第1张图片

 

2、上传到/usr/local  , 加压并重命名 为MySQL

tar  -zxvf  mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz  

mv   mysql-5.7.26-linux-glibc2.12-x86_64  mysql

 

3、安装MySQL

创建mysql用户,并授予权限

adduser mysql

chown mysql:mysql -R /usr/local/mysql

 

cd    /usr/local/mysql 

./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

linux安装MySQL5.7 tar.gz_第2张图片

 

4、修改配置文件 /etc/my.cnf  (一般系统自带该文件,没有就手动创建)

[mysqld]
port=3306
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
user=mysql
max_connections=100
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

#忽略大小写
lower_case_table_names=1

#设置编码
character-set-server=utf8
collation-server=utf8_general_ci

#IP绑定
#bind-address=192.168.8.100


[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid



#客户端连接设置
[client]
# 和上面要相同才行
socket=/usr/local/mysql/mysql.sock

default-character-set=utf8

 

4、开启mysql服务

./support-files/mysql.server start     (启动可能会报错,参考后面报错)

./support-files/mysql.server start

 

5、将mysql进程放入系统进程中

 

cp support-files/mysql.server /etc/init.d/mysqld

 

 

6、重启MySQL

service mysqld restart

 

7、设置MySQL环境变量

 

vim /etc/profile

export PATH=$PATH:/usr/local/mysql/bin

source /etc/profile

8、登陆MySQL(使用随机密码)

linux安装MySQL5.7 tar.gz_第3张图片

 

9、修改密码(将密码修改成root)

alter user 'root'@'localhost' identified by 'root' ;

 

10、设置远程连接

 

use mysql ;

update user set user.Host='%' where user.User='root' ;

flush privileges ;

linux安装MySQL5.7 tar.gz_第4张图片

 

 

 

 

 

11、报错:

1、启动服务时报错

[root@CentOS-05 mysql]# ./support-files/mysql.server start
Starting MySQL.2019-06-12T11:33:15.879193Z mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
The server quit without updating PID file (/var/lib/mysql/C[FAILED].pid).

解决:  修改  /etc/my.cnf

[mysqld]
port=3306
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
user=mysql
max_connections=100
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

#忽略大小写
lower_case_table_names=1

#设置编码
character-set-server=utf8
collation-server=utf8_general_ci

#IP绑定
#bind-address=192.168.8.100


[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid



#客户端连接设置
[client]
# 和上面要相同才行
socket=/usr/local/mysql/mysql.sock

default-character-set=utf8

 再次启动即可

 

2、  CentOS 7.5 启动MySQL报错

./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize     报错:
./bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
 

解决:

yum -y install numactl就可以 了

 

 

遇到各种报错可以查看日志,能解决很多问题:  

tail -100f /var/log/mysqld.log 

 

更多MySQL报错解决 参考https://blog.csdn.net/u010003835/article/details/79719337

 

 

 

 

 

 

 

你可能感兴趣的:(Linux,MySQL)