linux下用二进制包cmake和mysql安装mysql_00 - Linux系统通过RPM方式 | cmake方式安装MySQL | 二进制包免编译安装 | Windows下安装MySQL | M...

0.检查系统是否安装其他版本的MYSQL数据

yum list installed|grep mysql

yum-y remove mysql-libs.x86_641.检查Linux版本:

[root@mysqlcmake~]#cat /etc/redhat-release

CentOS release 6.10(Final)

[root@mysqlcmake~]#uname -r # 内核

2.6.32-754.17.1.el6.x86_64

[root@mysqlcmake~]#uname -m # 系统版本

x86_642.安装cmake#cmake下载地址:https://cmake.org/files/v2.8/

tar xzf cmake-2.8.8.tar.gz

cd cmake-2.8.8 #>> CMake has bootstrapped. Now run gmake.

./configure --prefix=/opt/cmake

gmake

make&&make install

cd ..

ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake3.安装依赖包

yum install ncurses-devel -y4.添加用户和组

groupadd mysql

useradd mysql-s /sbin/nologin -M -g mysql-s表示指定用户所用的shell,此处为/sbin/nologin,表示不登录。-M表示不创建用户主目录。-g表示指定用户的组名为mysql。4.安装MySQL

tar xzf mysql-5.5.62.tar.gz

cmake .-DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.62\-DMYSQL_DATADIR=/application/mysql-5.5.62/data \-DMYSQL_UNIX_ADDR=/application/mysql-5.5.62/tmp/mysql.sock \-DWITH_EXTRA_CHARSETS=gbk,gb2312,utf8,ascii \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNOBASE_STORAGE_ENGINE=1\-DWITH_FEDERATED_STORAGE_ENGINE=1\-DWITH_BLACKHOLE_STORAGE_ENGINE=1\-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1\-DWITHOUT_PARTITION_STORAGE_ENGINE=1\-DWITH_FAST_MUTEXES=1\-DWITH_ZLIB=bundled \-DENABLED_LOCAL_INFILE=1\-DWITH_READLINE=bundled \-DWITH_EMBEDDED_SERVER=1\-DWITH_DEBUG=0#去掉以下两个字符集,需要时再调整(如果确定字符集可以直接添加)

-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \

make&&make install5.为MySQL安装路径设置不带版本号的软链接/application/mysql

ln-s /application/mysql-5.5.62/ /application/mysql6.创建MySQL数据库配置文件并对数据库目录授权#MySQL5.5数据库默认为用户提供了多个配置文件模板,但是MySQL5.6的support-files目录下已经没有配置文件模板了

cd /root/Downloads/mysql-5.5.62cp support-files/my-small.cnf /etc/my.cnf #用最小的文件,生产可以根据硬件选择:my-innodb-heavy-4G.cnf

7.配置环境变量

echo'export PATH=/application/mysql/bin:$PATH' >> /etc/profile

tail-l /etc/profile

source/etc/profile

echo $PATH8.初始化数据库文件

chown-R mysql.mysql /application/mysql/chown-R 1777 /tmp/ #1777 粘贴位,作用是让用户无法删除文件,只可以进行读写

cd/application/mysql/scripts/./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql#--basedir=/application/mysql/为MySQL的安装路径,--datadir为数据文件目录。

#另,注意mysql_install_db和MySQL5.1的路径不同,MySQL5.1不在MySQL bin路径下了

9.配置并启动MySQL数据库

cd/root/Downloads/mysql-5.5.62cp support-files/mysql.server /etc/init.d/mysqld

chmod+x /etc/init.d/mysqld/etc/init.d/mysqld start#解决错误

#mysqld_safe Directory '/application/mysql-5.5.62/tmp' for UNIX socket file don't exists.

mkdir /application/mysql-5.5.62/tmp

chown-R mysql.mysql /application/mysql/

10.初始化密码/application/mysql/bin/mysqladmin -u root password 'password'

11.删除无用配置

select user,hostfrommysql.user;

deletefrom mysql.user where user='';

deletefrom mysql.user where host='mysqlcmake'; #可能是你设置的host

delete from mysql.user where host='::1';

剩下:+------+-----------+

| user | host |

+------+-----------+

| root | 127.0.0.1 |

| root | localhost |

+------+-----------+

12.开机自启

chkconfig mysqld on

chkconfig--list mysqld13.查看系统安装语言

cat/etc/sysconfig/i18n#如果没有,则添加LANG="en_US.UTF-8"

你可能感兴趣的:(linux下用二进制包cmake和mysql安装mysql_00 - Linux系统通过RPM方式 | cmake方式安装MySQL | 二进制包免编译安装 | Windows下安装MySQL | M...)