您好,登錄后才能下訂單哦!
本文主要給大家簡單講講linux7.2系統(tǒng)下實現二進制安裝MySQL8.0.11方法,相關專業(yè)術語大家可以上網查查或者找一些相關書籍補充一下,這里就不涉獵了,我們就直奔主題吧,希望linux7.2系統(tǒng)下實現二進制安裝MySQL8.0.11方法這篇文章可以給大家?guī)硪恍嶋H幫助。
1、下載二進制軟件包:
mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
2、添加MySQL用戶和組:
[root@localhost ~]# userdel mysql (因為是新系統(tǒng),所以就把現有的MySQL用戶給刪除了) [root@localhost ~]# groupadd mysql [root@localhost ~]# useradd -g mysql mysql [root@localhost ~]# passwd mysql (MySQL密碼要設置的復雜一點,或者在創(chuàng)建用戶的時候設置不讓登陸系統(tǒng))
3、創(chuàng)建安裝MySQL目標,并解壓軟件到指定目錄
[root@localhost ~]# mkdir -p /mysql/data [root@localhost ~]# chown -R mysql.mysql /mysql [root@localhost ~]# tar zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -C /mysql [root@localhost ~]# cd /mysql [root@localhost ~]# mv mysql-8.0.11-linux-glibc2.12-x86_64 / mysql [root@localhost ~]# chown -R mysql.mysql /mysql
4、初始化數據庫
[root@localhost ~]# su - mysql
[mysql@localhost ~]$ vim /mysql/my.cnf
[client] socket=/mysql/data/mysql.sock [mysqld] server-id=142 port = 3306 basedir=/mysql/mysql datadir=/mysql/data socket=/mysql/data/mysql.sock log-error=/mysql/data/mysqld.log pid-file=/mysql/data/mysqld.pid log-bin=/mysql/data/binlog slow_query_log_file = /mysql/data/slow.log log_slave_updates expire_logs_days=7 binlog_format=ROW #default_authentication_plugin=mysql_native_password ---修改密碼加密方式。(看文中最后的解釋) gtid-mode = on enforce-gtid-consistency = 1 skip_slave_start=1 innodb_buffer_pool_size = 1000M innodb_buffer_pool_instances = 2 innodb_log_file_size = 100M innodb_log_files_in_group = 3 innodb_log_buffer_size = 24M innodb_flush_log_at_trx_commit = 1 innodb_file_per_table = 1 innodb_flush_method = O_DIRECT innodb_io_capacity = 200 innodb_io_capacity_max = 600 innodb_thread_concurrency = 0 innodb_autoinc_lock_mode = 2 innodb_lock_wait_timeout = 60 innodb_read_io_threads = 4 innodb_write_io_threads = 4 innodb_max_dirty_pages_pct = 80 innodb_autoextend_increment = 512 innodb_checksum_algorithm = NONE max_connect_errors = 1000 max_connections = 500 connect_timeout = 300 wait_timeout = 86400 interactive_timeout = 86400
[mysql@localhost mysql]$ /mysql/mysql/bin/mysqld --defaults-file=/mysql/my.cnf --user=mysql --basedir=/mysql/mysql/ --datadir=/mysql/data/ --initialize
其中,root的默認密碼在:/mysql/data/mysqld.log 日志中,打開查看即可
5、啟動MySQL
[root@localhost mysql]# /mysql/mysql/bin/mysqld_safe --defaults-file=/mysql/my.cnf --user=mysql & [root@localhost mysql]# /mysql/mysql/bin/mysql -uroot -p -S /mysql/data/mysql.sock mysql> set password='123456'; mysql> flush privileges; mysql> \s -------------- /mysql/mysql/bin/mysql Ver 8.0.11 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL) Connection id: 11 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 8.0.11 MySQL Community Server - GPL Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 UNIX socket: /mysql/data/mysql.sock Uptime: 10 min 31 sec Threads: 2 Questions: 10 Slow queries: 0 Opens: 124 Flush tables: 2 Open tables: 100 Queries per second avg: 0.015 --------------
(注意:這里啟動數據庫一定要用MySQL8.0安裝包自帶的客戶端才可以登錄,即要使用MySQL8.0安裝包的命令進行登錄數據庫,要不然會報錯,如:
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded:)
注意:
在mysql8.0下,默認變成了default_authentication_plugin=caching_sha2_password,包括你剛初始化的root用戶也是這個認證加密方式,這樣的結果是讓你除非用新的協(xié)議驅動,例如必須用8.0自帶的mysql客戶端才行,不然就連接不上數據庫.
在mysql5.7環(huán)境里,雖然可以設置default_authentication_plugin來改變認證加密方式,但是一般人不會去設置.所以默認使用的認證加密方式是mysql_native_password
解決方法:
①:在初始化的時候在配置文件中加入,如下,mysql_native_password 這種認證方法就會很多客戶端的認證加密方式一樣。
vim my.cnf
[mysqld]
default_authentication_plugin=mysql_native_password
②:使用命令行模式更改用戶的密碼加密認證方式:
mysql> select Host,User,plugin,authentication_string from mysql.user; --看下面的root用戶的認證方式和其他用戶都是不一樣的, +-----------+------------------+-----------------------+------------------------------------------------------------------------+ | Host | User | plugin | authentication_string | +-----------+------------------+-----------------------+------------------------------------------------------------------------+ | localhost | mysql.infoschema | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | mysql.session | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | mysql.sys | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | root | caching_sha2_password | $A$005$T?yK{e`l{mrnZd|0iETvMwJ197qvnDXttfzdZX98q6xvFBwXuWd3ioPfnV7 | +-----------+------------------+-----------------------+------------------------------------------------------------------------+ 4 rows in set (0.00 sec) mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; ---在修改密碼的時候指定密碼加密認證方式 Query OK, 0 rows affected (0.11 sec) mysql> select Host,User,plugin,authentication_string from mysql.user; ---再次查看所有用戶都一樣了,和5.7版本一樣 +-----------+------------------+-----------------------+-------------------------------------------+ | Host | User | plugin | authentication_string | +-----------+------------------+-----------------------+-------------------------------------------+ | localhost | mysql.infoschema | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | mysql.session | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | mysql.sys | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | localhost | root | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | +-----------+------------------+-----------------------+-------------------------------------------+ 4 rows in set (0.00 sec)
另外,在MySQL8.0授權和創(chuàng)建用戶更加嚴格了,在MySQL5.7可以使用命令如下:
MySQL [(none)]> grant all privileges on *.* to 'test_user'@'192.168.2.%' identified by '123123'; ----MySQL5.7創(chuàng)建用戶授權的方法,報錯了,
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by '123123'' at line 1
在MySQL8.0中必須先創(chuàng)建用戶再授權:
MySQL > create user 'test_user'@'%' identified by '123456'; --先創(chuàng)建用戶
Query OK, 0 rows affected (0.03 sec)
MySQL > grant all privileges on *.* to 'test_user'@'%' with grant option; --再授權
Query OK, 0 rows affected (0.05 sec)
linux7.2系統(tǒng)下實現二進制安裝MySQL8.0.11方法就先給大家講到這里,對于其它相關問題大家想要了解的可以持續(xù)關注我們的行業(yè)資訊。我們的板塊內容每天都會捕捉一些行業(yè)新聞及專業(yè)知識分享給大家的。
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。