亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

linux 安裝 mysql 8.0.19 詳細(xì)步驟及問題解決方法

 更新時(shí)間:2020年02月27日 11:33:34   作者:艷陽高照中最亮的星  
這篇文章主要介紹了linux 安裝 mysql 8.0.19 詳細(xì)步驟,本文給大家列出了常見問題及解決方法,通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

最近買了個(gè)騰訊云服務(wù)器,搭建環(huán)境。

該筆記用于系統(tǒng)上未裝過mysql的干凈系統(tǒng)第一次安裝mysql。自己指定安裝目錄,指定數(shù)據(jù)文件目錄。

linux系統(tǒng)版本: CentOS 7.3 64位

安裝源文件版本:mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

mysql安裝位置:/software/mysql

數(shù)據(jù)庫文件數(shù)據(jù)位置:/data/mysql

注:未防止混淆,這里都用絕對(duì)路徑執(zhí)行命令

        除了文件內(nèi)容中的#,這里所有帶#都是linux命令

  >mysql 是mysql的命令

步驟:

1、在根目錄下創(chuàng)建文件夾software和數(shù)據(jù)庫數(shù)據(jù)文件/data/mysql

#mkdir /software/
#mkdir /data/mysql

2、上傳mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz文件到/software下

--------------------

這里我下載的帶了router和test的mysql-8.0.19-linux-glibc2.12-x86_64.tar文件,所以多一部解壓xz

--------------------
#cd /software/
#xz -d mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz
#tar -xvf mysql-8.0.19-linux-glibc2.12-x86_64.tar

3、更改解壓縮后的文件夾名稱

#mv /software/mysql-8.0.19-linux-glibc2.12-x86_64/ /software/mysql

4、創(chuàng)建mysql用戶組和mysql用戶

#groupadd mysql

#useradd -r -g mysql mysql

5、關(guān)聯(lián)myql用戶到mysql用戶組中

#chown -R mysql:mysql /software/mysql/
#chown -R mysql:mysql /data/mysql/
#chown -R mysql /software/mysql/
#chown -R mysql /data/mysql

6、更改mysql安裝文件夾mysql/的權(quán)限

#chmod -R 755 /software/mysql/

7、安裝libaio依賴包,系統(tǒng)自帶的有這個(gè)依賴包所以不需要安裝,不過自帶的依賴包會(huì)報(bào)錯(cuò)

查詢是否暗轉(zhuǎn)libaio依賴包

#yum search libaio

如果沒安裝,可以用下面命令安裝

#yum install libaio

8、初始化mysql命令

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

在執(zhí)行上面命令時(shí)特別要注意一行內(nèi)容  

[Note] A temporary password is generated for root@localhost: o*s#gqh)F4Ck

root@localhost: 后面跟的是mysql數(shù)據(jù)庫登錄的臨時(shí)密碼,各人安裝生成的臨時(shí)密碼不一樣

如果初始化時(shí)報(bào)錯(cuò)如下:

error while loading shared libraries: libnuma.so.1: cannot open shared objec

是因?yàn)閘ibnuma安裝的是32位,我們這里需要64位的,執(zhí)行下面語句就可以解決

#yum install numactl.x86_64

執(zhí)行完后重新初始化mysql命令

9、啟動(dòng)mysql服務(wù)

# sh /software/mysql/support-files/mysql.server start

上面啟動(dòng)mysql服務(wù)命令是會(huì)報(bào)錯(cuò)的,因?yàn)闆]有修改mysql的配置文件,報(bào)錯(cuò)內(nèi)容大致如下:

./support-files/mysql.server: line 239: my_print_defaults: command not found

./support-files/mysql.server: line 259: cd: /usr/local/mysql: No such file or directory

Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

10、修改Mysql配置文件

#vim /software/mysql/support-files/mysql.server

修改前

if test -z "$basedir"
then
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
if test -z "$datadir"
then
datadir=/usr/local/mysql/data
fi
sbindir=/usr/local/mysql/bin
libexecdir=/usr/local/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi

修改后

if test -z "$basedir"
then
basedir=/software/mysql
bindir=/software/mysql/bin
if test -z "$datadir"
then
datadir=/data/mysql
fi
sbindir=/software/mysql/bin
libexecdir=/software/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi

保存退出

#cp /software/mysql/support-files/mysql.server /etc/init.d/mysqld

#chmod 755 /etc/init.d/mysqld

11、修改my.cnf文件

#vi /etc/my.cnf

將下面內(nèi)容復(fù)制替換當(dāng)前的my.cnf文件中的內(nèi)容

[client]
no-beep
socket =/software/mysql/mysql.sock
# pipe
# socket=0.0
port=3306
[mysql]
#原文的utf8指向UTF8MB3,后續(xù)版本要改為UTF8MB4,一步到位吧
default-character-set=UTF8MB4
[mysqld]
basedir=/software/mysql
datadir=/data/mysql
port=3306
pid-file=/software/mysql/mysqld.pid
#skip-grant-tables
skip-name-resolve
socket = /software/mysql/mysql.sock
character-set-server=utf8
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true
# Server Id.
server-id=1
max_connections=2000
#query_cache_size在8.0版本已經(jīng)移除,故注釋
#query_cache_size=0
table_open_cache=2000
tmp_table_size=246M
thread_cache_size=300
#限定用于每個(gè)數(shù)據(jù)庫線程的棧大小。默認(rèn)設(shè)置足以滿足大多數(shù)應(yīng)用
thread_stack = 192k
key_buffer_size=512M
read_buffer_size=4M
read_rnd_buffer_size=32M
innodb_data_home_dir = /data/mysql
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=16M
innodb_buffer_pool_size=256M
innodb_log_file_size=128M
innodb_thread_concurrency=128
innodb_autoextend_increment=1000
innodb_buffer_pool_instances=8
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=300
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0
back_log=80
flush_time=0
join_buffer_size=128M
max_allowed_packet=1024M
max_connect_errors=2000
open_files_limit=4161
#query_cache_type在8.0版本已經(jīng)移除,故注釋
#query_cache_type=0
sort_buffer_size=32M
table_definition_cache=1400
binlog_row_event_max_size=8K
sync_master_info=10000
sync_relay_log=10000
sync_relay_log_info=10000
#批量插入數(shù)據(jù)緩存大小,可以有效提高插入效率,默認(rèn)為8M
bulk_insert_buffer_size = 64M
interactive_timeout = 120
wait_timeout = 120
log-bin-trust-function-creators=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

保存退出

12、啟動(dòng)mysql

#/etc/init.d/mysqld start

新版本的安裝包會(huì)報(bào)錯(cuò),錯(cuò)誤內(nèi)容如下:

Starting MySQL.Logging to '/data/mysql/SZY.err'.
2018-07-02T10:09:03.779928Z mysqld_safe The file /usr/local/mysql/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information
ERROR! The server quit without updating PID file (/software/mysql/mysqld.pid).

因?yàn)樾掳姹镜膍ysql安全啟動(dòng)安裝包只認(rèn)/usr/local/mysql這個(gè)路徑。

解決辦法:

方法1、建立軟連接

#cd /usr/local/mysql
#ln -s /sofware/mysql/bin/myslqd mysqld

方法2、修改mysqld_safe文件(有強(qiáng)迫癥的同學(xué)建議這種,我用的這種)

# vim /software/mysql/bin/mysqld_safe

將所有的/usr/local/mysql改為/software/mysql

保存退出。(可以將這個(gè)文件拷出來再修改然后替換)

13、登錄mysql

這里我登陸不了,被denny了,類似這樣的錯(cuò)誤:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)。

參考https://cloud.tencent.com/developer/article/1188636

改為這個(gè)操作:

1.停止mysql數(shù)據(jù)庫

/etc/init.d/mysqld stop

 (或者直接 kill -9 [PID]  殺進(jìn)程?。?/p>

2.執(zhí)行如下命令

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

3.使用root登錄mysql數(shù)據(jù)庫

mysql -u root mysql

4.更新root密碼

最新版MySQL請(qǐng)采用如下SQL:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';

5.刷新權(quán)限

mysql> FLUSH PRIVILEGES;

6.退出mysql

mysql> quit

7.重啟mysql

/etc/init.d/mysqld restart

8.使用root用戶重新登錄mysql

mysql -uroot -p
 Enter password: <輸入新設(shè)的密碼newpassword>
---------------------------------------------------------------------------------------------------------------------------
#/software/mysql/bin/mysql -u root –p

14、輸入臨時(shí)密碼。臨時(shí)密碼就是第8條root@localhost:后面的內(nèi)容

15、修改mysql的登錄密碼

>mysql set password=password('root');
>mysql grant all privileges on *.* to root@'%' identified by 'root';
>mysql flush privileges;

16、完成,此時(shí)mysql的登錄名root  登錄密碼root

總結(jié)

到此這篇關(guān)于linux 安裝 mysql 8.0.19 詳細(xì)步驟及問題解決方法的文章就介紹到這了,更多相關(guān)linux安裝mysql8.0.19 內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Mysql數(shù)據(jù)庫5.7升級(jí)到8.4的實(shí)現(xiàn)

    Mysql數(shù)據(jù)庫5.7升級(jí)到8.4的實(shí)現(xiàn)

    很多情況需要升級(jí)MySQL的數(shù)據(jù)庫版本,本文主要介紹了Mysql數(shù)據(jù)庫5.7升級(jí)到8.4的實(shí)現(xiàn),文中通過圖文介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2024-06-06
  • 詳解Mysql和Oracle之間的誤區(qū)

    詳解Mysql和Oracle之間的誤區(qū)

    mysql 和Oracle 在開發(fā)中的使用是隨處可見的,那就簡(jiǎn)單去了解一下這倆款火的不行的數(shù)據(jù)庫。
    2021-05-05
  • mysql服務(wù)啟動(dòng)不了解決方案

    mysql服務(wù)啟動(dòng)不了解決方案

    最近在Windows 2003上的MySQL出現(xiàn)過多次正常運(yùn)行時(shí)無法連接數(shù)據(jù)庫故障,現(xiàn)象是無法連接數(shù)據(jù)庫,也無法停止MySQL或重啟MYSQL,由于每次都是草草嘗試各種方法搞定即可本文將詳細(xì)介紹解決方法
    2012-11-11
  • MySQL 超大表快速刪除方式

    MySQL 超大表快速刪除方式

    這篇文章主要介紹了MySQL 超大表快速刪除方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • MySQL創(chuàng)建新用戶、增加賬戶的2種方法及使用實(shí)例

    MySQL創(chuàng)建新用戶、增加賬戶的2種方法及使用實(shí)例

    這篇文章主要介紹了MySQL創(chuàng)建新用戶、增加賬戶的2種方法及使用實(shí)例,本文同時(shí)也介紹了更新和修改密碼的方法,需要的朋友可以參考下
    2014-12-12
  • MySql在Mac上的安裝與配置詳解

    MySql在Mac上的安裝與配置詳解

    這篇文章主要介紹了MySql在Mac上的安裝配置,需要的朋友可以參考下
    2017-05-05
  • MySQL5.7.10 安裝文檔教程詳解

    MySQL5.7.10 安裝文檔教程詳解

    這篇文章主要介紹了MySQL5.7.10 安裝文檔教程詳解,需要的朋友可以參考下
    2017-02-02
  • mysql如何獲取自增id

    mysql如何獲取自增id

    這篇文章主要介紹了mysql如何獲取自增id問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-07-07
  • Windows(x86,64bit)升級(jí)MySQL 5.7.17免安裝版的詳細(xì)教程

    Windows(x86,64bit)升級(jí)MySQL 5.7.17免安裝版的詳細(xì)教程

    這篇文章主要介紹了Windows(x86,64bit)升級(jí)MySQL 5.7.17免安裝版的詳細(xì)教程,需要的朋友可以參考下
    2017-02-02
  • CentOS6.9下mysql 5.7.17安裝配置方法圖文教程

    CentOS6.9下mysql 5.7.17安裝配置方法圖文教程

    這篇文章主要為大家詳細(xì)介紹了CentOS6.9下mysql 5.7.17安裝配置方法圖文教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-10-10

最新評(píng)論