Center os6.5 mysql
1 # yum -y install mysql-server mysql mysql-dev
2 启动mysql # service mysqld start
3 为root用户配置一个密码 # mysqladmin -u root password '密码'
4 用root用户登录 # mysql -u root -p
5 输入密码登录到mysql
6 看一下数据库 mysql> show databases;
7 此时数据库已经安装完成了,但是此时只有本机能访问,局域网内其他用户无法访问到
8 切入mysql数据库 mysql> use mysql;
9 查询用户表信息 mysql> select host,user,password from user;
10 删除无用的用户 delete from user where password='';
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 永久关闭防火墙