如何启动MySql服务
/etc/init.d/mysqld startservice mysqld startCentos 7.x 系统sysctl start mysqld
检测端口是否运行
lsof -i :3306netstat -lntup |grep 3306
设置或修改MySql密码
设置密码mysql -uroot -ppassword -e "set passowrd for root = passowrd('passowrd')"mysqladmin -uroot passowrd "NEWPASSWORD"更改密码mysqladmin -uroot passowrd oldpassowrd "NEWPASSWORD"use mysql;update user set passowrd = PASSWORD('newpassword') where user = 'root'; flush privileges;msyql 5.7以上版本修改默认密码命令 alter user 'root'@'localhost' identified by 'root'
查看当前数据库的字符集
show create database DB_NAME;
查看当前数据库版本
mysql -Vmysql -uroot -ppassowrd -e "use mysql;select version();"
查看当前登录用户
mysql -uroot -ppassowrd -e "select user();"