准备编译环境
因为我的Linux是刚安装的,需要安装很多的必要程序。
1 2 |
|
下载MySQL
进入http://dev.mysql.com/downloads/mysql/ 的source/Generic Linux (Architecture Independent), Compressed TAR Archive,文件mysql-5.6.16.tar.gz。
wget http:
//dev
.mysql.com
/get/Downloads/MySQL-5
.6
/mysql-5
.6.16.
tar
.gz(下载MySQL编译包)
tar
xvf mysql-5.6.16.
tar
.gz (解压编译包)
cd
mysql-5.6.16(进入源码目录)
编译源码
接下来组织项目
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 |
|
注意,这个cmake是替代以前的./configure 步骤。如果你需要更多的参数,请参考http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html。
有时候会出现类似的问题。
Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source. — If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://example.com:80
使用参数-DENABLE_DOWNLOADS=1 自动下载。
有网络限制,设置http代理
export http_proxy=http://example.com:80
。环境变量http_proxy
也为 curl 等其他工具所用。尽管 yum 可以识别大写或小写的 http_proxy,但curl 要求环境变量的名称是小写。
如果这个cmake这个步骤有出现问题,解决后重新再cmake一次。如果输出类似这样,那么就好了。
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 |
|
接着编译源码
1 |
|
编译时间缓慢,等待中…
修改文件权限,生成数据库
groupadd mysql
useradd
-r -g mysql mysql
cd
/usr/local/mysql
chown
-R mysql:mysql .
scripts
/mysql_install_db
--user=mysql --ldata=
/data/mysql/data
chown
-R root .
chown
-R mysql data
说明:参数--ldata
说明你的数据文件存放的目录,如果你使用默认的路径,那么这个参数可以去除。如果你不增加此参数,但是在配置文件(见下方的datadir配置)中指定了其他的目录,那么会在启动MySQL的时候出现类似的提示:
Starting MySQL. ERROR! The server quit without updating PID file (/data/mysql/data/VM_208.pid).
出现这个的解决办法就是增加--ldata
参数,指定和配置文件中datadir
相同的值,重新执行mysql_install_db即可。
设置配置文件(替换my.conf)
http://pan.baidu.com/s/1mgA8UBu 文件下载
MySQL 5.6.8开始,就不在分发my.cnf等配置的demo,所以想随便拿一个用都比较麻烦。
my.cnf的配置文件的默认读取顺序为
FILE NAME(上面的优先) | PURPOSE |
---|---|
/etc/my.cnf | Global options |
/etc/mysql/my.cnf | Global options |
| Global options |
$MYSQL_HOME/my.cnf | Server-specific options |
defaults-extra-file | The file specified with --defaults-extra-file= , if any |
~/.my.cnf | User-specific options |
~/.mylogin.cnf | Login path options |
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
启动MySQL,开机自动启动设置
手动启动MySQL。
1 2 3 4 |
|
在上面的步骤后,开机自动启动设置
1 2 3 |
|
修改root密码
默认的密码是空的,很危险,需要修改一下。
在此之前,为方便调用mysql,我们先生成一个mysql的软链。
1 |
|
然后修改密码
1 2 |
|
use mysql;
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
update user set host = '%' where user = 'root';
更改下表内权限
select host, user from user;
查看
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
| demo | |
| demo | root |
| localhost | |
+-----------+------+
flush privileges;
通过上面的步骤,就可以使用MySQL数据库了,另外可以为mysql安装phpmyadmin作为前端的管理界面。
打开root远程访问
改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
CODE:mysql -u root -p123
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
运行完最后一句话后出了个错误ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
于是又去找解决方案,发现先
mysql> select host from user where user = 'root';
+-----------------------+
| host |
+-----------------------+
| % |
| 127.0.0.1 |
| localhost.localdomain |
+-----------------------+
3 rows in set (0.00 sec)
host已经有了%这个值,所以直接运行命令:
mysql>flush privileges;
欢迎大家访问记忆碎片 www.debris.cn ,在碎片中寻找你的记忆!
转载于:https://blog.51cto.com/debris/1622679