Linux手动安装mysql5.7.28

1.官网下载
2.解压tar.xz文件:

 1:xz -d file.tar.xz 
 2:tar -xvf file.tar.xz

3.重命名

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

4.添加系统mysql组和mysql用户

groupadd mysql 
useradd -r -g mysql mysql

5.修改解压后的mysql目录权限

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

5.创建mysql数据仓库目录:

 mkdir /usr/local/data/mysql-data

6.修改mysql-data的权限

chown -R root:root .
chown -R mysql:mysql .

7.修改mysql的数据库数据默认位置vi /etc/my.cnf,修改后内容如下(注意修改datadir跟socket的值)

        [mysqld]
		datadir=/usr/local/data/mysql-data
		basedir=/usr/local/src/mysql
		socket=/usr/local/data/mysql-data/mysql.sock
		user=mysql
		port=3306
		character-set-server=utf8
		# 取消密码验证
		#skip-grant-tables
		# Disabling symbolic-links is recommended to prevent assorted security risks
		symbolic-links=0
		# skip-grant-tables
		[mysqld_safe]
		log-error=/var/log/mysqld.log
		pid-file=/var/run/mysqld/mysqld.pid

8.初始化数据库

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

以上这步骤执行完成后会生成临时密码
A temporary password is generated for root@localhost: r#su##&WF0Xy
10.添加启动服务

cp /usr/local/src/mysql/support-files/mysql.server /etc/init.d/mysql

11.启动服务

service mysql start

12.修改root密码

 ./mysqladmin -uroot -p'r#su##&WF0Xy' password 111111

13.登录mysql(密码:111111)

bin/mysql -u root -p 

你可能感兴趣的:(mysql)