Linux-安裝MySQL數據庫

關鍵詞:mysql5.6;安裝包安裝;

MySQL

(1)查找並卸載系統已經安裝的mysql

# rpm -qa | grep mysql

# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64

(2)安裝libaio

鏈接:https://pan.baidu.com/s/1yP9dO1WxmZpurXJ2d4_tfA 密碼:qlyb

 

# rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm

(3)安裝MySQL

鏈接:https://pan.baidu.com/s/14hyu8ltY0zOWTu0GhHa8OA 密碼:pz06

 

# tar -xbf MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle.tar

 

# rpm -ivh MySQL*.rpm

(4)配置數據庫

 

# cp /usr/share/mysql/my-default.cnf /etc/my.cnf

 

# vim /etc/my.conf

 

備註:

cp拷貝dir1目錄的my-default.cnf,到dir2目錄下,命名爲my.cnf

數據庫配置文件【my.conf】

default-storage-engine = innodb

innodb_file_per_table

collation-server = utf8_general_ci

init-connect = 'SET NAMES utf8'

character-set-server = utf8

max_allowed_packet = 100M

 

(5)初始化並啓動數據庫

# cd /usr/bin/mysql_install_db

 

# service mysql start

# chkconfig mysql on

 

(6)修改數據庫臨時密碼

 

#    cat /root/.mysql_secret    # cat命令cat(concatenate)命令用於顯示文件的內容

 

#    mysqladmin -uroot -pDZxvfVLLeJQGR7Mq password 123456

 

%%YY:此處提示錯誤

mysqladmin: connect to server at 'localhost' failed

error:‘your password has expired, to log in you must change it using a client that that support expired passwords.’

 

停止mysql服務

# service mysql stop

 

mysql安全模式啓動,跳過權限控制表

# cd /usr

# mysqld_safe --user=mysql --skip-grant-tables

備註:

--skip-grant-tables:不啓動grant-tables(授權表),跳過權限控制。

--skip-networking :跳過TCP/IP協議,只在本機訪問(這個選項不是必須的。可以不用)

登錄mysql服務,使用mysql數據庫,查詢myqsl用戶信息

# mysql

mysql> use mysql;

mysql> select host,user,authentication_string,password_expired from user;

備註: 

authentication_string字段就是password用戶密碼;

password_expired字段,對應密碼是否過期,Y,過期,N,永不過期。

 

重置用戶名爲root的密碼爲123456,輸入SQL命令:

mysql>update user set authentication_string=PASSWORD('123456')   where user='root' ;

 

設置密碼永不過期

mysql>alter user 'root'@'localhost' password expire never;

mysql>update user set password_expired='N'   where user='root' \;

 

 #數據庫設置更新,生效,退出

mysql>flush privileges;

mysql>quit

bye

 

重新登錄mysql

#mysql -uroot -p123456

 

重啓數據庫服務

# service mysql restart

 

(7)創建zabbix數據庫及用戶並賦予相關權限

mysql -u root -p123456

 

CREATE DATABASE zabbix CHARACTER SET UTF8 COLLATE UTF8_BIN;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';

GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY '123456';

FLUSH PRIVILEGES;

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章