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、最後更換我們更改密碼的方法,問題就解決了 

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部署完畢

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章