一.编译环境
1).cmake
1.下载路径
文件名称:cmake-3.21.0-rc1.tar.gz
2.解压后进入目录
3. ./bootstrap
4.make && make install
查看cmake版本 cmake --version
2).pkg-config 安装
1.下载 https://pkg-config.freedesktop.org/releases/
2.解压进入目录 ./configure --with-internal-glib
3.make && make install
(编译mysql时报错 Curses library not found. Please install appropriate package,安装ncuses)
3).ncurses安装
1.下载 http://ftp.gnu.org/gnu/ncurses/
2.解压进入目录 ./configure --with-shared --without-debug --without-ada --enable-overwrite
3.make && make install
二.mysql安装
1.下载
https://downloads.mysql.com/archives/community/
文件名称:mysql-boost-5.7.33.tar.gz
2.解压后进入目录
3. cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/opt/mysql-5.7.33/boost
说明:如果编译出错,没有通过,检测参数后重新运行配置,需要删除CMakeCache.txt文件
#make clean
#rm -f CMakeCache.txt
4.make && make install
该命令中可以通过添加-j参数指定多线程工作,如make -j2 && make install -j2 则使用2个CPU核进行make
安装时间挺长的,慢慢等待
5.
shell>groupadd mysql
shell>useradd -g mysql mysql
shell> cd /usr/local/mysql
shell>chown -R mysql .
shell>chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql
shell>chown -R root .
shell>chown -R mysql var
6.初始化mysql /usr/local/mysql/data data目录下一定要为空才行
shell> bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
// /usr/local/mysql为mysql安装位置 /usr/local/mysql/data数据库文件存放位置
7.加入服务中(可以使用 service mysqld start/stop/status)
shell>cp support-files/mysql.server /etc/init.d/mysqld
systemctl enable mysqld
mysql.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable mysqld
8.启动mysql:
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &
9.修改环境变量
在/etc/profile 中新增一行
PATH=/usr/local/mysql/bin:$PATH
10.保存退出
source /etc/profile
三.创建用户和数据库
1.使用root登录
shell>/usr/local/mysql/bin/mysql -uroot
Linux下装完mysql后root用户默认密码是空值,即提示要输入密码按回车键即可。
2.set password = password('admin');
3.创建zbm用户
mysql> create user zbmidentified by "zbm";
4.创建zbm数据库
mysql> create database if not exists zbm;
5.授权zbm用户拥有zbm数据库的所有权限
mysql> grant all privileges on zbm.* to zbm@localhost identified by 'zbm';
mysql> grant all privileges on zbm.* to "zbm"@"%" identified by "zbm" with grant option;
6.刷新系统权限表
mysql> flush privileges;