1. 检查是否安装
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
*可见已经安装了库文件,应该先卸载,不然会出现覆盖错误。注意卸:载时使用了--nodeps选项,忽略了依赖关系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
2.安装MySQL的服务器端软件,注意切换到root用户
前提:已经将rpm包上传到某个目录,rpm包可以去官网下载。
rpm -ivh mysql-community-common-5.7.7-0.3.rc.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.7-0.3.rc.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.7-0.3.rc.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.7-0.3.rc.el6.x86_64.rpm
mysqld --initialize
cd /var/lib/mysql
chown -R mysql.mysql *
service mysqld start
此时查看/var/log/mysqld.log查找root用户初始密码:***
登陆 :mysql -uroot -p***
登陆后修改密码>set password=password('gaoyx');
安装完成后,安装进程会在Linux中添加一个mysql组,以及属于mysql组的用户mysql
可通过检查端口是否开启来查看MySQL是否正常启动:
[root@localhost JavaEE]#netstat -anp|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 34693/mysqld
3.修改数据库配置
3.1设置表名不区分大小写
vi /etc/my.cnf
[mysqld] 下面加
lower_case_table_names = 1
1是不区分 0是区分
重启: service mysqld restart
mysql> show variables like "%case%";
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | OFF |
| lower_case_table_names | 1 |
+------------------------+-------+
3.2设置数据库编码
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+
或者一开始都是latin时,使用
mysql>set character_set_database=utf8;
注意:配置十分重要,请在建库导数据之前就设置,配置设置后的新建的库才会应用这些配置。
rpm安装方式比较简单,只要有rpm包,上传后按照步骤操作就好啦~~