linux--mysql 8.0.16--裸机安装
参考: https://www.cnblogs.com/warmsmile/p/10210739.html
https://www.cnblogs.com/yg_zhang/p/10424926.html
1.删除自带的mysql
rpm -qa | grep mysql
rpm -e --nodeps mysql-libs-5.1.73-5.el6_6.x86_64
rpm -qa | grep mariadb
#### mariadb-libs-5.5.60-1.el7_5.x86_64
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
2.下载tar包
wget https://cdn.mysql.com//downloads/mysql-8.0/mysql-8.0.16-linux-glibc2.12-x86_64.tar
3.解压tar包
注意这里是*.tar文件,解压时和*.tar.gz包有所区别,需要解压两次 第一次解压出*.tar.xz,在解压*.tar.xz
tar -xvf mysql-8.0.16-linux-glibc2.12-x86_64.tar
tar xvjf mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz
如果报错如下,安装xz,在解压就正常了
yum -y install xz
vim /etc/my.cnf
[client]
port=3306
socket=/tmp/mysql/mysql.sock
[mysqld]
port=3306
user=mysql
socket=/tmp/mysql/mysql.sock
basedir=/data/mysql-8.0.16
datadir=/data/mysql-8.0.16/data
log-error=error.log
transaction_isolation = read-committed
character-set-server = utf8mb4
#collation-server = utf8mb4_general_ci
collation-server = utf8mb4_bin
lower_case_table_names = 1
#skip-grant-tables
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
#user=mysql
# disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/tmp/mysql/log/mysqld.log
pid-file=/tmp/mysql/run/mysqld/mysqld.pid
#log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
groupadd mysql
useradd -g mysql mysql
mkdir /tmp/mysql
chown -r mysql:mysql /tmp/mysql
chown -r mysql:mysql /data/mysql-8.0.16
chmod -r 755 /tmp/mysql /data/mysql-8.0.16
chown -r root:root /tmp/mysql
chown -r root:root /data/mysql-8.0.16
chmod -r 755 /tmp/mysql /data/mysql-8.0.16
./bin/mysqld --initialize --user=mysql --basedir=/data/mysql-8.0.16/ --datadir=/data/mysql-8.0.16/data/
报错解决,安装依赖
yum install -y libaio
还有报错,安装依赖
yum -y install numactl
在执行初始化,成功
启动 mysql
cp /data/mysql/support-files/mysql.server /etc/init.d/mysql
cp /data/mysql/support-files/mysql.server /etc/init.d/mysql
./support-files/mysql.server start
service mysql start
service mysqld start
7.初始化密码
初始化时并没有出现 初始密码,因此需要修改密码。
注释 skip-grant-tables,可以使用无密码登录
mysql -u root -p 回车,不输入密码再回车
1.清空密码
use mysql;
update user set authentication_string='' where user='root';
2.退出之后禁用无密码登陆 skip-grant-tables
3.无密码登录,在第一部清空了密码
mysql -u root -p
输入密码是直接回车。
修改密码如下,免密码登无法执行修改
alter user 'root'@'localhost' identified by '123456';
远程连接设置:
新版的的mysql版本已经将创建账户和赋予权限的方式分开了
1、创建账户 create user 'root'@'%' identified by '$$123456';
2、赋予权限 grant all privileges on *.* to 'root' @'%';
3、刷新权限 flush privileges
使用navicat视图工具连接报错解决:
mysql8 之前的版本中加密规则是mysql_native_password,
而在mysql8之后,加密规则是caching_sha2_password,
解决问题方法有两种,
第一种是升级navicat驱动,
第二种是把mysql用户登录密码加密规则还原成mysql_native_password.
这里使用第二种方式实现:
alter user 'root'@'%' identified by '$$123456' password expire never; #修改加密规则
alter user 'root'@'%' identified with mysql_native_password by '$$123456'; #更新一下用户的密码
flush privileges; #刷新权限
mysql> alter user 'root'@'localhost' identified by '$$123456' password expire never;
query ok, 0 rows affected (0.02 sec)
mysql> alter user 'root'@'localhost' identified with mysql_native_password by '$$123456';
query ok, 0 rows affected (0.02 sec)
mysql> flush privileges;
query ok, 0 rows affected (0.01 sec)
mysql> select host, user, authentication_string, plugin from user ;
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| host | user | authentication_string | plugin |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| % | root | $a$005$i?iex(2/2o!yom?jyuiwz2i0ci1h15d5gfb6fvgc/3uvjceixvnzdoy/ue2 | caching_sha2_password |
| localhost | mysql.infoschema | $a$005$thisisacombinationofinvalidsaltandpasswordthatmustneverbrbeused | caching_sha2_password |
| localhost | mysql.session | $a$005$thisisacombinationofinvalidsaltandpasswordthatmustneverbrbeused | caching_sha2_password |
| localhost | mysql.sys | $a$005$thisisacombinationofinvalidsaltandpasswordthatmustneverbrbeused | caching_sha2_password |
| localhost | root | *f0d06dbf9e3eaf787baea71c2eac5540b0218a2b | mysql_native_password |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
5 rows in set (0.00 sec)
mysql> alter user 'root'@'%' identified by '$$123456' password expire never;
query ok, 0 rows affected (0.08 sec)
mysql> alter user 'root'@'%' identified with mysql_native_password by '$$123456';
query ok, 0 rows affected (0.01 sec)
mysql> flush privileges;
query ok, 0 rows affected (0.01 sec)
mysql> select host, user, authentication_string, plugin from user ;
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| host | user | authentication_string | plugin |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| % | root | *f0d06dbf9e3eaf787baea71c2eac5540b0218a2b | mysql_native_password |
| localhost | mysql.infoschema | $a$005$thisisacombinationofinvalidsaltandpasswordthatmustneverbrbeused | caching_sha2_password |
| localhost | mysql.session | $a$005$thisisacombinationofinvalidsaltandpasswordthatmustneverbrbeused | caching_sha2_password |
| localhost | mysql.sys | $a$005$thisisacombinationofinvalidsaltandpasswordthatmustneverbrbeused | caching_sha2_password |
| localhost | root | *f0d06dbf9e3eaf787baea71c2eac5540b0218a2b | mysql_native_password |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
5 rows in set (0.00 sec)
mysql>
至此,安装完成
上一篇: 来一个自己写的轮播图