1 # yum -y install mysql-server mysql mysql-devmysql
2 啓動mysql # service mysqld startsql
3 爲root用戶配置一個密碼 # mysqladmin -u root password '密碼'數據庫
4 用root用戶登陸 # mysql -u root -p vim
5 輸入密碼登陸到mysql 編碼
6 看一下數據庫 mysql> show databases;spa
7 此時數據庫已經安裝完成了,可是此時只有本機能訪問,局域網內其餘用戶沒法訪問到.net
8 切入mysql數據庫 mysql> use mysql;rest
9 查詢用戶表信息 mysql> select host,user,password from user;server
10 刪除無用的用戶 delete from user where password='';blog
11 再次查詢 此時只有一個用戶了 綁定機器名是localhost 也就是隻有本機下能夠訪問到
12 將localhost 修改成% mysql> update user set host='%';
13 修改後須要刷新權限 mysql> flush privileges;
此時關閉防火牆後局域網內其餘用戶也能夠訪問了
設置mysql編碼爲中文
cd /etc/
vim my.cnf
打開/etc/my.cnf修改配置文件:
[root@Web_Mysql ~]# vim /etc/my.cnf
在[client]下添加
default-character-set=utf8
在[mysqld]下添加
default-character-set=utf8
:wq #保存
重啓mysql
service mysqld restart
[root@Web_Mysql ~]# mysql -u root -p
Enter password: (輸入密碼)
mysql> show variables like 'character%';
+-----------------------------------------+------------------------------------------+
| Variable_name | Value |
+-----------------------------------------+------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
OK;
==========================================================
CentOS7下解決yum install mysql-server沒有可用包的問題
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
mysql-community-release-el7-5.noarch.rpm
ls -1 /etc/yum.repos.d/mysql-community*
yum install mysql-server
==============================
hkconfig mysqld on mysql 服務開機自啓
chkconfig iptables off 永久關閉防火牆