第一次裝好mysql後要設定密碼
初始是沒有密碼的
1連線mysql
Mysql –h主機地址 –u使用者名稱 –p使用者密碼2為使用者設定密碼
Mysqladmin –uroot password "123456"
Mysql –uroot –p
12345
5.0.24版本的不能使用空密碼來登入,和以前的版本不太一樣的地方.所以剛安裝好mysql後直接用mysql登入是不行的需要先設定密碼的,否則會出現:
[root@test1 local]# mysql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
3修改密碼:
mysqladmin -u使用者名稱 -p舊密碼 password 新密碼
4增加新使用者:
grant select on 資料庫.* to 使用者名稱@登入主機 identified by \"密碼\"
1.登入MySQL
登入MySQL的命令是mysql, mysql 的使用語法如下:
mysql [-u username] [-h host] [-p[password]] [dbname]
username 與 password 分別是 MySQL的使用者名稱與密碼,mysql的初始管理帳號是root,沒有密碼,注意:這個root使用者不是Linux的系統使用者。MySQL預設使用者是root,由於初始沒有密碼,第一次進時只需鍵入mysql即可。
[root@test1 local]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.16-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
出現了“mysql>”提示符,]
這說明你安裝是成功的。
2.MySQL預設沒有密碼,安裝完畢增加密碼的重要性是不言而喻的。
1、命令
usr/bin/mysqladmin -u root password 'new-password'
格式:mysqladmin -u使用者名稱 -p舊密碼 password 新密碼
2、例子
例1:給root加個密碼123456。
鍵入以下命令 :
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
注:因為開始時root沒有密碼,所以-p舊密碼一項就可以省略了。
3.增加了密碼後的登入格式如下:
mysql -u root -p
Enter password: (你自己設的密碼)
其中-u後跟的是使用者名稱,-p要求輸入密碼,回車後在輸入密碼處輸入密碼。
4.到這兒就基本OK,可以順利進入mysql