LAMP環境搭建教程(原創整理)
阿新 • • 發佈:2019-02-13
Query OK, 1 row affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
11、可以用幾種方法為root賬戶指定密碼,我們選擇用其中的一種。在mysql客戶端命令列上使用set password指定密碼,一定要使 用password()函式來加密密碼。例如下面設定localhost域的密碼為ios100。其他域可以使用同樣的語句,使用的SQL語句如下。
mysql> set password for 'root'@'localhost'=password('ios100');
Query OK, 0 rows affected (0.00 sec)
12、如果想退出mysql客戶端,可以在mysql客戶端提示符下輸入命令exit或者quit,還可以按鍵盤ctrl+c組合鍵,都可以從 mysql客戶端退出。因為已經給mysql伺服器的root賬號設定了密碼,所以再次登入mysql客戶端就要提供密碼才能進入。退出mysql客戶端 和重新啟動mysql客戶端的控制檯命令如下。
mysql> exit
Bye
[ [email protected] mysql]# bin/mysql -u root -h localhost -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6 to server version: 5.0.18-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
如果想關閉mysql伺服器,在命令列使用mysql伺服器的mysqladmin命令,通過-u引數給出mysql資料庫管理員使用者名稱root和通過-p引數給出密碼,即可關閉mysql伺服器。如下示:
[ [email protected] mysql]# bin/mysqladmin -u root -p shutdown
Enter password:
STOPPING server from pid file /usr/local/mysql/var/localhost.pid
130207 21:27:05 mysqld ended
[1]+ Done /usr/local/mysql/bin/mysqld_safe --user=mysql
13、mysql伺服器和apache伺服器一樣也有必要設定為開機自動執行,設定方法進入到mysql原始碼目錄/usr/local/src /mysql-5.0.18,將子目錄support-files下的mysql.server檔案複製到/etc/rc.d/init.d目錄中,並重 命名為mysqld,命令列如下。
[ [email protected] mysql]# cd /usr/local/src/mysql-5.0.18
[[email protected] mysql-5.0.18]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
修改一下許可權
[[email protected] mysql-5.0.18]# chown root.root /etc/rc.d/init.d/mysqld
[[email protected] mysql-5.0.18]# chmod 755 /etc/rc.d/init.d/mysqld
把mysqld新增到chkconfig中
[[email protected] mysql-5.0.18]# chkconfig --add mysqld
在圖形和字符集介面下自動啟動mysqld
[[email protected] mysql-5.0.18]# chkconfig --level 3 mysqld on
[[email protected] mysql-5.0.18]# chkconfig --level 5 mysqld on
再使用chkconfig --list命令檢查設定
[[email protected] mysql-5.0.18]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:off 5:on 6:off