更改密码
1、mysql -u root -p
2、Enter password:***
3、mysql>use mysql #选择数据库
4、Database changed
5、mysql>UPDATE user SET password=PASSWORD("新密码") WHERE user='你的用户名'
6、mysql>FLUSH PRIVILEGES
7、mysql>quit
更改用户名:
1、mysql -u root -p
2、Enter password:***
3、mysql>use mysql #选择数据库
4、Database changed
5、mysql>update user set user="新用户名" where user="root"#将用户名为root的改为新用户名
6、mysql>flush privileges#刷新权限
7、mysql> exit
扩展资料:
mysql常用命令:
安装(基于centos)
yum -y install mariadb mariadb-server #centos7版本
yum -y install mysql mysql-server #centos7以下版本
启动
service mysqld start #开启 centos7以下版本
chkconfig mysqld on #设置开机自启
OR
systemctl start mariadb #centos7
systemctl enable mariadb
设置密码
1 、mysqladmin -u root -p123 password '1234' #修改root用户密码
2、进入mysql库修改user表
mysql>use mysql
mysql>update user set password=password('你的密码') where user='root'
mysql>flush privileges
登录
mysql #本地登录,默认用户root,空密码,用户为[email protected]
mysql -uroot -p1234 #本地登录,指定用户名和密码,用户为[email protected]
mysql -uroot P端口号 -h 192.168.31.95 -p密码 #远程登录,用户为[email protected]
查看
ps aux |grep mysqld #查看进程
netstat -an |grep 3306 #查看端口
1.用管理员身份打开cmd, cd到MySQL安装目录(一定得用管理员身份,不然net命令使用不了) 2.删除安装目录下的data,没有的话可以忽略 3.使用net stop mysql命令停掉mysql服务,如果这个命令提示不存在,可以先进入bin目录执行以下命令即可 mysqld --install 4.进入bin目录后,运行命令: mysqld --initialize --user=mysql --console , 初始化mysql安装目录, 此时data文件夹会自动生成,临时密码也会显示到控制台, 可以记住这个密码 5.使用net start mysql启动mysql服务 6.使用刚才的密码连接进入mysql7.输入以下命令即可修改密码 ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' 8.然后就可以愉快地使用新密码了欢迎分享,转载请注明来源:内存溢出
评论列表(0条)