MySQL8.0.18源码安装

1、源码安装cmake3.17.1,安装详见https://blog.csdn.net/baidu_38432732/article/details/106568431

2、源码安装gcc-8.3.0,至少5.3.0版本,详见https://blog.csdn.net/baidu_38432732/article/details/106533091

3、下载MySQL包 下载地址:http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-boost-8.0.18.tar.gz

4、解压源码包并进行编译安装

# tar -xf mysql-boost-8.0.18.tar.gz
# cd mysql-boost-8.0.18
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DSYSCONFDIR=/etc \
-DWITH_EXTRA_CHARSETS=all \
-DMYSQL_DATADIR=/data/mysql \
-DWITH_BOOST=/opt/mysql-8.0.18/boost \
-DFORCE_INSOURCE_BUILD=1 \
-DCMAKE_CXX_COMPILER=/usr/local/gcc-8.3.0/bin/g++ \
-DDEFAULT_CHARSET=utf8
# make
# make install

5、配置文件修改

# vim /etc/my.cnf
[mysqld]
port=3306
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
pid-file=/var/run/mariadb/mariadb.pid
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[client]
socket=/var/lib/mysql/mysql.sock


[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
socket=/var/lib/mysql/mysql.sock

创建mysql用户并对上面配置文件的相关目录文件赋予mysql用户权限

useradd mysql -s /sbin/nologin

6、数据初始化,注意会显示我们的初始密码

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

7、将源码下的mysql-file下的mysql.server拷贝到我们的/etc/init.d/,并启动mysql

# cp /opt/mysql-8.0.18/mysql-files/mysql.server /etc/init.d/
# service mysql start

8、登录mysql

[root@localhost mysql-8.0.18]# mysql -uroot -hlocalhost -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.18

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> 
mysql> grant all on *.* to root@"123456" with grant option;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> ^DBye

9、最后更换我们更改密码的方法,问题就解决了 

首先,修改validate_password_policy参数的值

mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)


validate_password_length(密码长度)参数默认为8,我们修改为1

mysql> set global validate_password.length=1;
Query OK, 0 rows affected (0.00 sec)

2
4,完成之后再次执行修改密码语句即可成功

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> alter user user() identified by "123456";
Query OK, 0 rows affected (0.09 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
mysql>^DBye

此时我们还不能访问

我们需要重新授权

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host="%" where user="root";
Query OK, 1 row affected (0.13 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)

 

至此mysql部署完毕

 

当改密码成功后,navicat登录报错解决问题方法

报错内容

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.00 sec)

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值