Linux下配置mysql數據庫

1 linux下安裝mysql數據庫

               一、將安裝包上傳到linux目錄下mysql

                              /usr/local/wollolinux

               二、使用 tar命令在當前目錄下解壓mysqlsql

                              解壓命令爲:數據庫

                                             [root@bogon wollo]# tar -zxvf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz安全

               三、將解壓後的mysql文件夾複製到usr目錄下的local目錄中ide

                              複製命令爲:spa

                                             [root@bogon wollo]# cp -r mysql-5.6.31-linux-glibc2.5-x86_64 /usr/local/mysql命令行

               四、進入到usr/local/mysql目錄下rest

                              命令爲:server

                                             [root@bogon wollo]# cd /usr/local/mysql/

               五、在mysql目錄下,建立用戶組

                              命令爲:

                                             [root@bogon mysql]# groupadd mysql

               六、在mysql目錄下,建立用戶:

                              命令爲:

                                             [root@bogon mysql]# useradd -r  -g mysql mysql

               七、在mysql目錄下,給用戶賦予mysql文件夾的操做權限

                              命令爲:

                                             [root@bogon mysql]# chgrp  -R mysql .

               八、在mysql目錄下,變動mysql用戶具有操做本級目錄的權限:

                              命令爲:

                                             [root@bogon mysql]# chown -R mysql .

               九、在mysql目錄下,判斷ect/my.cnf文件是否存在,存在則刪除

                              判斷命令爲:

                                             [root@bogon mysql]# ls /etc/my.cnf

                              刪除命令爲:

                                             [root@bogon mysql]# rm -rf /etc/my.cnf

               十、在mysql目錄下,初始化數據庫

                                             命令爲:[root@bogon mysql]# ./scripts/mysql_install_db --user=mysql

               十一、在mysql目錄下,將mysql的my-default.cnf文件複製到ect下

                              命令爲:

                                             [root@bogon mysql]# cp support-files/my-default.cnf /etc/my.cnf

               十二、在mysql目錄下,複製服務文件到etc目錄下

                              命令爲:

                                             [root@bogon mysql]# cp support-files/mysql.server      /etc/rc.d/init.d/mysql

               1三、在mysql目錄下,啓動mysql服務:

                              命令爲:

                                             [root@bogon mysql]# service mysql start

               1四、啓動成功後在控制檯輸入 mysql -u root -p進入mysql命令行

                                             若是提示沒有mysql命令,則添加軟鏈接。

                                             命令爲:

                                                            [root@bogon mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

               1五、再次輸入mysql -u root -p,若是提示mysql密碼,則表示安裝和配置成功

2 mysql的密碼修改

               一、進入/etc/my.cnf 在[mysql]下添加skip-grant-tables 啓動安全模式

命令:vi /etc/my.cnf

               二、重啓服務:

                              命令:service mysql restart

               三、登陸mysql,輸入密碼時直接回車

                              命令:  mysql -u root -p

               四、進入到mysql後,先使用mysql數據庫

                              命令:use mysql

               五、修改密碼

                              命令: update user set password= passworD ("bjsxt") where user='root'

               六、刷新權限

                              命令: flush privileges;

               七、退出

                              命令:exit;

3 mysql的遠程連接配置

               一、使用mysql -u root -p 回車,而後輸入密碼,進入到mysql命令狀態

               二、切換爲mysql庫

                              命令爲:use mysql;

               三、修改root帳戶的連接權限

                             命令爲: grant all privileges on *.* to root@'%' identified by "bjsxt";

               四、刷新權限

                              命令:flush privileges;

               五、退出

                              命令:exit

               六、在防火牆中放行3306端口號

                              命令: vi /etc/sysconfig/iptables

        七、在Navicat中創建mysql鏈接

               注意:重啓linux後須要重啓mysql才能用navicat鏈接

                                             service mysql start 

相關文章
相關標籤/搜索