#### 1、下载安装包 http://dev.MySQL.com/downloads/mysql/#downloads 推荐下载通用安装方法的TAR包
以上为默认存在的情况,如无,执行添加命令:
[root@localhost ~]$groupadd mysql[root@localhost ~]$useradd -r -g mysql mysql//useradd -r参数表示mysql用户是系统用户,不可用于登录系统。123如果改变默认安装路径,则需要 1)/etc/my.cnf、/etc/init.d/mysqld中修改 basedir=’/apps/mysql’ datadir=’/apps/mysql/data’ 2)创建ln mkdir -p /usr/local/mysql/bin ln -s /apps/mysql/bin/mysqld /usr/local/mysql/bin/mysqld
[root@localhost mysql]$[root@localhost mysql]$ cp -a ./support-files/my-default.cnf /etc/my.cnf[root@localhost mysql]$ cp -a ./support-files/mysql.server /etc/init.d/mysqld1234[root@localhost mysql]$ cd bin/[root@localhost bin]# ./mysqld_safe --user=mysql &[1] 2932[root@localhost bin]# 2016-06-01T22:27:09.708557Z mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.2016-06-01T22:27:09.854913Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data12345[root@localhost bin]# /etc/init.d/mysqld restartShutting down MySQL..2016-06-01T22:27:50.498694Z mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended SUCCESS! Starting MySQL. SUCCESS! [1]+ Done ./mysqld_safe --user=mysql[root@localhost bin]$ //设置开机启动[root@localhost bin]$ chkconfig --level 35 mysqld on[root@localhost bin]$1234567896.初始化密码
mysql5.7会生成一个初始化密码,而在之前的版本首次登陆不需要登录。
[root@localhost bin]$ cat /root/.mysql_secret # PassWord set for user 'root@localhost' at 2016-06-01 15:23:25 ,xxxxxR5H9[root@localhost bin]$./mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 2Server version: 5.7.12Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql> SET PASSWORD = PASSWORD('123456');Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)123456789101112131415161718192021227.添加远程访问权限
mysql> use mysql; Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> update user set host = '%' where user = 'root';Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> select host, user from user;+-----------+-----------+| host | user |+-----------+-----------+| % | root || localhost | mysql.sys |+-----------+-----------+//重启生效
/etc/init.d/mysqld restart
经过以上处理,Mysql就可以正常启动使用了,但此时会存在大小写敏感的问题,需要进行以下处理:
用root帐号登录后,在/etc/my.cnf 中的[mysqld]后添加添加lower_case_table_names=1,重启MYSQL服务,这时已设置成功:不区分表名的大小写; lower_case_table_names参数详解: lower_case_table_names = 0 其中 0:区分大小写,1:不区分大小写 MySQL在Linux下数据库名、表名、列名、别名大小写规则是这样的: 1、数据库名与表名是严格区分大小写的; 2、表的别名是严格区分大小写的; 3、列名与列的别名在所有的情况下均是忽略大小写的; 4、变量名也是严格区分大小写的;
新闻热点
疑难解答