1. 下载解压 mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz 到指定目录
tar -xvf mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
2. 移动到指定目录修改名称
cd /usr/local/
mv mysql-8.0.13-linux-glibc2.12-x86_64/ mysql
3. 创建用户和用户组并授权
groupadd mysql
useradd -r -g mysql mysql
进入mysql文件下授权所有的文件
cd mysql/
chown -R mysql:mysql ./
4. 创建data文件,初始化 eoe.R)*gf7eY
mkdir data
cd bin
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data;
等待执行完成后记录下密码 localhost:后面的密码,第11步登录时候用
5. 修改权限
cd /usr/local/mysql
chown -R root:root ./
chown -R mysql:mysql data
(查看权限是否修改成功)
ll
6. my.cnf
cd /usr/local/mysql
cd /usr/local/mysql/support-files
touch my-default.cnf
chmod 777 ./my-default.cnf
cd ..
cp support-files/my-default.cnf /etc/my.cnf
7. 编辑 /etc/my.cnf 添加如下配置
[mysqld]
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
tmpdir = /tmp
port = 3306
#lower_case_table_names = 1
# server_id = .....
# socket = .....
#lower_case_table_names = 1
max_allowed_packet=100M
default-authentication-plugin = mysql_native_password
#lower_case_file_system = on
#lower_case_table_names = 1
log_bin_trust_function_creators = ON
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/usr/local/mysql/data/error.log
pid-file=/usr/local/mysql/data/mariadb.pid
# include all files from the config directory
!includedir /etc/my.cnf.d
8. 开机自启,进入/usr/local/mysql/support-files进行设置
cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql
chkconfig --list mysql
9. 配置路径
vim /etc/ld.so.conf
添加一行:
/usr/local/mysql/lib
10. 配置环境变量
vim /etc/profile
添加如下内容:
# MYSQL ENVIRONMENT
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
重置配置生效:
source /etc/profile
service mysql start
11. 登录,输入第四部生成的密码:eoe.R)*gf7eY
mysql -uroot -p
12. 修改密码修改权限以及远程连接打开
alter user user() identified by 'root';
use mysql;
select user,host from user;
update user set host="%" where user="root";
flush privileges;
exit;
service mysql restart;
重新登录:
mysql -uroot -p
执行命令:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
flush privileges;
exit;
service mysql restart;
13. 测试连接
文档:LInux安装MySQL-8.0.13-总结.note
链接:http://note.youdao.com/noteshare?id=7dd645a524ae89ba97892762d40978b1&sub=252E2666D70A407F9CE040AFD5A0EE36