云盘下载链接:https://pan.baidu.com/s/1CwH3yKNoQ_dUX4Q2xrA5Aw
提取码:jxbk
# tar -xvf mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz
# mv mysql-8.0.13-linux-glibc2.12-x86_64 mysql
# mv mysql /usr/local/
# cd /usr/local/
# groupadd mysql
# useradd -r -g mysql mysql
# cd mysql/ #注意:进入mysql文件下授权所有的文件
# chown -R mysql:mysql ./
#passwd mysql #修改mysql用户密码
# mkdir data
# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
# chown -R root:root ./
# chown -R mysql:mysql data
复制过去,其实也就是空白页,一开始没有my-default.cnf这个文件,可以用# touch my-default.cnf命令创建一个,并配置权限
# chmod 777 ./my-default.cnf
# cd support-files/
# touch my-default.cnf
# chmod 777 ./my-default.cnf
# cd ../
# cp support-files/my-default.cnf /etc/my.cnf
# vim /etc/my.cnf
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# 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 = 5186
#lower_case_table_names = 1
# server_id = .....
# socket = .....
#lower_case_table_names = 1
max_allowed_packet=32M
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
如果后期mysql运行报错,可以直接到log-error = /usr/local/mysql/data/error.log目录下直接查看错误日志
命令:cat /usr/local/mysql/data/error.log
# cd support-files/
# cp mysql.server /etc/init.d/mysql
# chmod +x /etc/init.d/mysql
# chkconfig --add mysql
如果命令没有,在需要处理chkconfig
# rpm -aq |grep chkconfig
# export PATH=/sbin:$PATH
# chkconfig
# echo $PATH
# PATH="$PATH":/sbin
# echo $PATH
# vim /etc/ld.so.conf
添加如下内容:
/usr/local/mysql/lib
# vim /etc/profile
# source /etc/profile
添加如下内容:
#MYSQL ENVIRONMENT
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
#启动mysql服务
[root@localhost bin]# service mysql start
Starting MySQL.Logging to '/usr/local/mysql/data/error.log'.
.. SUCCESS!
[root@localhost bin]#
#修改mysql密码
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.02 sec)
mysql>
# mysql -uroot -p #进入数据库
> use mysql;#进入数据库
> select host, user, authentication_string, plugin from user;#查看用户信息
> GRANT ALL ON *.* TO 'root'@'%';#授权root用户可以远程登陆
> flush privileges;#立即生效
> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Kuaigui2019!';#修改root用户密码
> FLUSH PRIVILEGES;#立即生效
> exit;#退出
# service mysql restart#重启mysql服务