3、安裝MySQL的服務,服務名自己定義為MySQL. 1)、進入DOS窗口 2)、執行安裝MySQL服務名的命令: D:/AppServ/MySQL/bin/mysqld-nt -install mysql --defaults-file="D:/Appserv/MySQL/my.ini" 出現Service successfully installed.表示安裝成功。
然后打開服務窗口(在運行框中輸入services.msc即可打開服務窗口,然后可以找到mysql服務了,右鍵mysql服務屬性,在彈出的窗口中可以看到以下信息:) D:/AppServ/MySQL/bin/mysqld-nt --defaults-file=D:/Appserv/MySQL/my.ini mysql 則表示mysql會隨開機啟動而啟動!
3)、啟動MySQL服務 net start mysql MySQL服務正在啟動 . MySQL服務無法啟動。
4)、登陸MySQL服務器 mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 1 Server version: 5.1.32-community MySQL Community Edition (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>
注意:MySQL的管理員用戶名為root,密碼默認為空。
5)、查看數據庫 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.02 sec)
可以看到MySQL服務器中有三個數據庫。
6)、使用數據庫 mysql> use test Database changed
7)、查看數據庫中的表 mysql> show tables; Empty set (0.00 sec)
4、創建一個root用戶,密碼為"xiaohui"。 mysql>grant all on *.* to root@'%' identified by 'xiaohui' with grant option; Query OK, 0 rows affected (0.02 sec)
5、查看user表中的用戶 mysql> select User from user; +------+ | User | +------+ | root | +------+ 1 row in set (0.00 sec)
6、重啟MySQL:更改了MySQL用戶后,需要重啟MySQL服務器才可以生效。 net stop mysql MySQL 服務正在停止.. MySQL 服務已成功停止。
net start mysql MySQL 服務正在啟動 . MySQL 服務已經啟動成功。
7、重新登陸MySQL服務器 mysql -uroot -pxiaohui Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 1 Server version: 5.1.32-community MySQL Community Edition (GPL) Type 'help;' or '/h' for help. Type '/c' to clear the buffer. mysql>
如果修改密碼后net startmysql出現不能啟動mysql的1067錯誤,則可以使用以下辦法解決: 使用cmd命令:D:/Appserv/mysql/bin/mysqladmin -uroot -p shutdown,然后輸入密碼,再net start mysql 就沒有這個錯誤提示了!