linux下 MySQL安装配置

时间:2022-03-03 17:12:06

一.安装

yum -y install mysql-server
 
字符集配置:
在[mysqld]节点下添加:
default-character-set=utf8
character-set-server=utf8


自启动配置
chkconfig mysqld on
chkconfig  --list mysqld

修改防火墙
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT

service iptables restart

二.配置

service mysqld start

初始化
mysql -u root   (sqlplus / as sysdba)
查看目前mysql的用户
select user,host,password from mysql.user

修改密码(linux下)
set password for root@localhost=password('111111');

set password for root@127.0.0.1=password('111111');

exit 退出

登录 
mysql -u root -p

删除匿名用户
delete from mysql.user where user="";

插入mysql 新用户
insert into mysql.user(Host,User,Password) values ("localhost","cyl",password("111111"));

使操作生效
flush privileges;