Linux下使用yum安装mysql

一、安装
1. 查看是否有安装mysql
yum list installed mysql*
rpm -qa | grep mysql*


2. 查看有没有安装包
yum list mysql*


3.安装mysql客户端
yum install mysql


4.安装mysql服务器
yum install mysql-server


二、配置数据库
1.数据库字符集设置,mysql配置文件中添加内容:default-character-set=utf8
vi /etc/my.cnf


三、启动和停止
1.启动mysql
server mysqld start或者/etc/init.d/mysqld start

2.开机启动
chkconfig -add mysqld

3.查看开机启动设置是否成功
chkconfig --list | grep mysql*

4.停止mysql
service mysqld stop


四、登录
1.创建root管理员
mysqladmin -u root password root

2.登录
mysql -uroot -proot

3.找回密码
service mysqld stop
mysqld_safe --user=root --skip-grant-tables
mysql -u root
use mysql
update user set password=password("root") where user="root"
flush privileges

猜你喜欢

转载自blob-lihe.iteye.com/blog/2159300