发新话题
打印

怎么初次进入mysql呢?解决登入问题和密码问题~

怎么初次进入mysql呢?解决登入问题和密码问题~

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

TOP

发新话题