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';
然後重啓服務,就可以使用用戶名密碼登陸服務器了