本文主要給大家簡(jiǎn)單講講linux7.2系統(tǒng)下實(shí)現(xiàn)二進(jìn)制安裝MySQL8.0.11方法,相關(guān)專(zhuān)業(yè)術(shù)語(yǔ)大家可以上網(wǎng)查查或者找一些相關(guān)書(shū)籍補(bǔ)充一下,這里就不涉獵了,我們就直奔主題吧,希望linux7.2系統(tǒng)下實(shí)現(xiàn)二進(jìn)制安裝MySQL8.0.11方法這篇文章可以給大家?guī)?lái)一些實(shí)際幫助。
成都創(chuàng)新互聯(lián)主打移動(dòng)網(wǎng)站、網(wǎng)站設(shè)計(jì)、成都網(wǎng)站設(shè)計(jì)、網(wǎng)站改版、網(wǎng)絡(luò)推廣、網(wǎng)站維護(hù)、域名與空間、等互聯(lián)網(wǎng)信息服務(wù),為各行業(yè)提供服務(wù)。在技術(shù)實(shí)力的保障下,我們?yōu)榭蛻?hù)承諾穩(wěn)定,放心的服務(wù),根據(jù)網(wǎng)站的內(nèi)容與功能再?zèng)Q定采用什么樣的設(shè)計(jì)。最后,要實(shí)現(xiàn)符合網(wǎng)站需求的內(nèi)容、功能與設(shè)計(jì),我們還會(huì)規(guī)劃穩(wěn)定安全的技術(shù)方案做保障。
1、下載二進(jìn)制軟件包:
mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
2、添加MySQL用戶(hù)和組:
[root@localhost ~]# userdel mysql (因?yàn)槭切孪到y(tǒng),所以就把現(xiàn)有的MySQL用戶(hù)給刪除了) [root@localhost ~]# groupadd mysql [root@localhost ~]# useradd -g mysql mysql [root@localhost ~]# passwd mysql (MySQL密碼要設(shè)置的復(fù)雜一點(diǎn),或者在創(chuàng)建用戶(hù)的時(shí)候設(shè)置不讓登陸系統(tǒng))
3、創(chuàng)建安裝MySQL目標(biāo),并解壓軟件到指定目錄
[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、初始化數(shù)據(jù)庫(kù)
[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 ---修改密碼加密方式。(看文中最后的解釋?zhuān)? 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的默認(rèn)密碼在:/mysql/data/mysqld.log 日志中,打開(kāi)查看即可
5、啟動(dòng)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 --------------
(注意:這里啟動(dòng)數(shù)據(jù)庫(kù)一定要用MySQL8.0安裝包自帶的客戶(hù)端才可以登錄,即要使用MySQL8.0安裝包的命令進(jìn)行登錄數(shù)據(jù)庫(kù),要不然會(huì)報(bào)錯(cuò),如:
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded:)
注意:
在mysql8.0下,默認(rèn)變成了default_authentication_plugin=caching_sha2_password,包括你剛初始化的root用戶(hù)也是這個(gè)認(rèn)證加密方式,這樣的結(jié)果是讓你除非用新的協(xié)議驅(qū)動(dòng),例如必須用8.0自帶的mysql客戶(hù)端才行,不然就連接不上數(shù)據(jù)庫(kù).
在mysql5.7環(huán)境里,雖然可以設(shè)置default_authentication_plugin來(lái)改變認(rèn)證加密方式,但是一般人不會(huì)去設(shè)置.所以默認(rèn)使用的認(rèn)證加密方式是mysql_native_password
解決方法:
①:在初始化的時(shí)候在配置文件中加入,如下,mysql_native_password 這種認(rèn)證方法就會(huì)很多客戶(hù)端的認(rèn)證加密方式一樣。
vim my.cnf
[mysqld]
default_authentication_plugin=mysql_native_password
②:使用命令行模式更改用戶(hù)的密碼加密認(rèn)證方式:
mysql> select Host,User,plugin,authentication_string from mysql.user; --看下面的root用戶(hù)的認(rèn)證方式和其他用戶(hù)都是不一樣的, +-----------+------------------+-----------------------+------------------------------------------------------------------------+ | 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'; ---在修改密碼的時(shí)候指定密碼加密認(rèn)證方式 Query OK, 0 rows affected (0.11 sec) mysql> select Host,User,plugin,authentication_string from mysql.user; ---再次查看所有用戶(hù)都一樣了,和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授權(quán)和創(chuàng)建用戶(hù)更加嚴(yán)格了,在MySQL5.7可以使用命令如下:
MySQL [(none)]> grant all privileges on *.* to 'test_user'@'192.168.2.%' identified by '123123'; ----MySQL5.7創(chuàng)建用戶(hù)授權(quán)的方法,報(bào)錯(cuò)了,
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)建用戶(hù)再授權(quán):
MySQL > create user 'test_user'@'%' identified by '123456'; --先創(chuàng)建用戶(hù)
Query OK, 0 rows affected (0.03 sec)
MySQL > grant all privileges on *.* to 'test_user'@'%' with grant option; --再授權(quán)
Query OK, 0 rows affected (0.05 sec)
linux7.2系統(tǒng)下實(shí)現(xiàn)二進(jìn)制安裝MySQL8.0.11方法就先給大家講到這里,對(duì)于其它相關(guān)問(wèn)題大家想要了解的可以持續(xù)關(guān)注我們的行業(yè)資訊。我們的板塊內(nèi)容每天都會(huì)捕捉一些行業(yè)新聞及專(zhuān)業(yè)知識(shí)分享給大家的。