环境:
系统版本: Ubuntu 14.04.1
mysql版本: mysql-5.6.16
cmake版本: 3.10.1
下载相应的安装包:
mysql:(
https://dev.mysql.com/downloads/mysql/5.6.html#downloads
去此网站选择对应的系统版本与mysql版本)
cmake:
https://cmake.org/files/v3.10/cmake-3.10.1-Linux-x86_64.tar.gz
1.安装编译环境 gcc,g++ (我博客资源里面有deb整合安装包,名字为AiToMakoto.rar,里面有安装顺序)
2.编译安装cmake
解压cmake-3.10.1.tar.gz
cd cmake-3.10.1
依次运行
./bootstrap 配置
make -j8 编译
sudo make install 安装
检测: cmake -version 如出现版本,则安装成功
3. 编译并安装mysql
解压mysql,进入其目录,编译源码
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/data
-DSYSCONFDIR=/etc
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
-DENABLED_LOCAL_INFILE=1
-DWITH_READLINE=1
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock
-DMYSQL_TCP_PORT=3306
-DCOMPILATION_COMMENT="lq-edition"
-DENABLE_DTRACE=1
-DWITH_DEBUG=1
Error: 如报错
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
则需要安装 libncurses5-dev(ncurses-devel是centos的包)包
libncurses5-dev 包依赖 libtinfo-dev_5.9 -->(上面下载的资源包里面有)
将两个包安装好后
再次运行上面的cmake . -DCMAKE_********
编译: make
安装: sudo make install
4.配置mysql
⑴.建立配置文件:
cp support-files/my-default.cnf /etc/my.cnf
⑵.修改配置文件:
sudo vi /etc/my.cnf
[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
[mysqld]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
user=root
(因为我是用的root账户登录,如果你要用其他账户,如mysql账户,
则创建用户 adduser mysql,并且赋予权限chown -R mysql:mysql /usr/local/mysql
并且设置配置文件里面的user=mysql)
⑶.初始化数据库
cd /usr/local/mysql
sudo scripts/mysql_install_db --user=(配置文件里面的user)--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
⑷.通过服务启动mysql
cp support-files/mysql.server /etc/init.d/mysql
sudo chmod 755 /etc/init.d/mysql
启动:
sudo /etc/init.d/mysql start
关闭:sudo /etc/init.d/mysql stop
重启:sudo /etc/init.d/mysql restart
⑸.设置开机自启动
update-rc.d mysql defaults
⑹.修改root密码(因默认密码为空)
mysql -h127.0.0.1 -uroot -p
update mysql.user set password=password("你的root密码") where user='root';
flush privileges;
番外:
Navicat 无法连接 mysql时的解决办法:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '(你的root密码)' WITH GRANT OPTION;