centos安裝mysql數(shù)據(jù)庫(kù)(2018-09-28)

首先需要下載安裝文件3個(gè):

MySQL-client-5.6.37-1.el7.x86_64.rpm?

MySQL-devel-5.6.37-1.el7.x86_64.rpm?

MySQL-server-5.6.37-1.el7.x86_64.rpm

使用rpm安裝

rpm -ivh ./MySQL-server-5.6.37-1.el7.x86_64.rpm

若需查詢(xún)移除:

rpm -qa | grep -i MySQL

rpm -e MySQL-server-5.6.37-1.el7.x86_64.rpm

然后配置my.cnf到/etc下

my.cnf內(nèi)容如下:



[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 = 64M

# 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 = .....

# datadir = .....

# port = .....

# server_id = .....

# socket = .....

user=mysql

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

# 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 = 64M

sort_buffer_size = 2M

read_rnd_buffer_size = 2M

key_buffer_size = 64M

performance_schema_max_table_instances=400

table_definition_cache=400

table_open_cache=256

[client]

socket=/var/lib/mysql/mysql.sock

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES



使用如下命令啟動(dòng)

/etc/init.d/mysql start

第一次啟動(dòng)會(huì)創(chuàng)建一個(gè)隨機(jī)密碼,位于

/root/.mysql_secret最后一行

修改登陸密碼,登陸

mysql -u root -p

輸入剛才的隨機(jī)密碼,進(jìn)入mysql命令行

第一次登陸不能輸入其它命令,需執(zhí)行修改密碼命令

SET PASSWORD=PASSWORD('123456');

然后修改遠(yuǎn)程登陸的用戶(hù)名和密碼

use mysql;

update user set password=PASSWORD("123456") where user='root';

FLUSH PRIVILEGES;

quit;

若遠(yuǎn)程登陸失敗,可mysql執(zhí)行如下,插入遠(yuǎn)程登陸用戶(hù)名

use mysql;

update user set host='%' where user='root';

FLUSH PRIVILEGES;

安裝完成,

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容