centos7默认是不能安装mysql的,因为MySQL已经被收购了,所以我们采用源码安装
详细安装参考
https://www.cnblogs.com/piaoyang2087/articles/7908795.html
mysql启动参考文档
http://blog.chinaunix.net/uid-13642598-id-3153537.html
在启动mysql的时候要使用mysql/bin来启动
默认启动是如下
./mysqld --defaults-file=/usr/local/mysql/my.cnf --user=root
直接使用mysql就可以登陆,如果要设置用户名密码登陆的话需要先
使用mysql登陆,然后新增用户,
create user aftest@'%' identified by 'test';
grant all privileges on *.* to 'aftest'@'%' identified by 'test';
然后关闭服务
修改my.cnf文件,增加
[mysqld]
user=mysql
skip-grant-tables
create user aftest@'%' identified by 'test';
grant all privileges on *.* to 'aaa'@'localhost' identified by 'aaa';
./mysqld --defaults-file=/usr/local/mysql/my.cnf --user=root
update user set password=password("test") where user="aftest";
create user aaa@'localhost' identified by 'aaa';
然后重启服务,就可以使用用户名密码登陆服务器了