Linux下yum安装mysql
1.安装mysql 服务器端
yum -y install mysql-server mysql-devel
2.配置/etc/my.cnf
[client] default-character-set=utf8 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 #default-character-set=utf8 character-set-server=utf8 init_connect='SET NAMES utf8' [mysql] no-auto-rehash default-character-set=utf8 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
3.删除文件
rm -fr /var/lib/mysql/*
rm /var/lock/subsys/mysqld
killall mysqld
3 登陆等权限设置
登录mysql数据库:mysq -u root password 123456
首次使用创建root管理员和密码
(mysql -u root -p输入密码即可?)
mysql -u root;
use mysql ;
update user set password=password("123456") where user="root";
flush privileges;
4.忘记密码
service mysqld stop;
mysqld_safe --user=root --skip-grant-tables;
这一步骤执行的时候不会出现新的命令行,你需要重新打开一个窗口执行下面的命令
mysql -u root;
use mysql ;
update user set password=password("123456") where user="root";
flush privileges;
5.如果需要外网可以访问需要再做如下设置
授权用户可以从远程登陆
grant all PRIVILEGES on *.* to root@'%' identified by '123456';
flush privileges ;