Linux安裝mysql8.0.13步驟(轉(zhuǎn))
1.下載mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz的安裝包
2.解壓mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz
# tar -xvf mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz
3.將解壓的文件重命名mysql亲澡,并移動(dòng)到/usr/local目錄下
# mv mysql-8.0.13-linux-glibc2.12-x86_64 mysql# mv mysql /usr/local/
4.進(jìn)入到/usr/local目錄下,創(chuàng)建用戶和用戶組并授權(quán)
# cd /usr/local/# groupadd mysql# useradd -r -g mysql mysql# cd mysql/ #注意:進(jìn)入mysql文件下授權(quán)所有的文件# chown -R mysql:mysql ./ #passwd mysql #修改mysql用戶密碼
5.再/usr/local/mysql目錄下渴析,創(chuàng)建data文件夾
# mkdir data
6.初始化數(shù)據(jù)庫箱玷,并會(huì)自動(dòng)生成隨機(jī)密碼,記下等下登陸要用
# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
7.修改/usr/local/mysql當(dāng)前目錄得用戶
# chown -R root:root ./# chown -R mysql:mysql data
8.# cp support-files/my-default.cnf /etc/my.cnf
復(fù)制過去絮吵,其實(shí)也就是空白頁弧烤,一開始沒有my-default.cnf這個(gè)文件,可以用# touch my-default.cnf命令創(chuàng)建一個(gè)蹬敲,并配置權(quán)限
chmod 777 ./my-default.cnf
ln -s /usr/local/mysql/bin/mysql /usr/bin
# cd support-files/# touch my-default.cnf# chmod 777 ./my-default.cnf # cd ../# cp support-files/my-default.cnf /etc/my.cnf
9.配置my.cnf
# vim /etc/my.cnf
[mysqld] # Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin # These are commonly set, remove the # and set as required.basedir = /usr/local/mysqldatadir = /usr/local/mysql/datasocket = /tmp/mysql.socklog-error = /usr/local/mysql/data/error.logpid-file = /usr/local/mysql/data/mysql.pidtmpdir = /tmpport = 5186#lower_case_table_names = 1# server_id = .....# socket = .....#lower_case_table_names = 1max_allowed_packet=32Mdefault-authentication-plugin = mysql_native_password#lower_case_file_system = on#lower_case_table_names = 1log_bin_trust_function_creators = ON# Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
如果后期mysql運(yùn)行報(bào)錯(cuò)暇昂,可以直接到log-error = /usr/local/mysql/data/error.log目錄下直接查看錯(cuò)誤日志
命令:cat /usr/local/mysql/data/error.log
10.開機(jī)自啟莺戒,進(jìn)入/usr/local/mysql/support-files進(jìn)行設(shè)置
# cd support-files/# cp mysql.server /etc/init.d/mysql # chmod +x /etc/init.d/mysql
11.注冊(cè)服務(wù)
# chkconfig --add mysql
如果命令沒有,在需要處理chkconfig
# rpm -aq |grep chkconfig# export PATH=/sbin:$PATH# chkconfig# echo $PATH# PATH="$PATH":/sbin# echo $PATH
12.查看是否成功
13.etc/ld.so.conf要配置路徑急波,不然報(bào)錯(cuò)
# vim /etc/ld.so.conf 添加如下內(nèi)容:/usr/local/mysql/lib
14.配置環(huán)境變量
# vim /etc/profile# source /etc/profile 添加如下內(nèi)容:#MYSQL ENVIRONMENTexport PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
15.登陸从铲,這里輸入上面第6步隨機(jī)生成得密碼,細(xì)心點(diǎn)輸入澄暮,沒有顯示的名段,登陸成功如圖所示
#啟動(dòng)mysql服務(wù)
[root@localhost bin]# service mysql startStarting MySQL.Logging to '/usr/local/mysql/data/error.log'... SUCCESS!
[root@localhost bin]#
#修改mysql密碼
mysql> alter user 'root'@'localhost' identified by '123456';Query OK, 0 rows affected (0.02 sec)
mysql>
使用mysql 數(shù)據(jù)庫
mysql > use mysql;
特定用戶的host 修改
mysql > update user set host='%' where user='root';
指定用戶的授權(quán)
mysql > grant all privileges on test.* to root@'%'
16.開啟Navicat遠(yuǎn)程連接
# mysql -uroot -p #進(jìn)入數(shù)據(jù)庫> use mysql;#進(jìn)入數(shù)據(jù)庫> select host, user, authentication_string, plugin from user;#查看用戶信息> GRANT ALL ON *.* TO 'root'@'%';#授權(quán)root用戶可以遠(yuǎn)程登陸> flush privileges;#立即生效> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Kuaigui2019!';#修改root用戶密碼> FLUSH PRIVILEGES;#立即生效> exit;#退出# service mysql restart#重啟mysql服務(wù)