linux 使用cmake安装mysql

本文详述了在Linux环境下部署MySQL 5.5.32的具体步骤,包括用户组与用户创建、数据库包解压、配置文件调整、环境变量设定、权限配置、初始化、服务启动及root用户密码设置等关键环节。
1、创建mysql 用户组
[root@192 /] groupadd mysql
[root@192 /] useradd mysql -s /sbin/nologin -M -g mysql
[root@192 /] yum install ncurses-devel -y
2、选择数据库包解压
[root@192 /]# cd /application/mysql-5.5.32
[root@192 mysql-5.5.32]cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql -DMYSQL_DATADIR=/application/mysql/data -DMYSQL_UNIX_ADDR=/application/mysql/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_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=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0
[root@192 mysql-5.5.32] make && make install
3、 将配置文件替换my.cnf中的内容
[root@192 /]# cp /application/mysql/support-files/my-small.cnf /etc/my.cnf
4、配置环境变量
[root@192 /]#  echo 'export PATH=/application/msyql/bin:$PATH' >> /etc/profile
[root@192 /]# source /etc/profile
[root@192 /]# which mysqldump
/application/mysql/bin/mysqldump
5、授权
[root@192 mysql]# chown -R mysql.mysql /application/mysql
[root@192 mysql-5.5.32]# chmod -R 1777 /tmp/
6、初始化
[root@192 scripts]# cd /application/mysql/scripts/
[root@192 scripts]# ./mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql

Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/application/mysql/bin/mysqladmin -u root password 'new-password'
/application/mysql/bin/mysqladmin -u root -h 192.168.205.135 password 'new-password'

Alternatively you can run:
/application/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.

You can start the MySQL daemon with:
cd /application/mysql ; /application/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /application/mysql/scripts/mysqlbug script!
7、拷贝文件
[root@192 /]# cp /application/mysql/support-files/mysql.server  /etc/init.d/mysqld
8、启动
[root@192 /]# chmod +x /etc/init.d/mysqld 
[root@192 /]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS! 
[root@192 /]# mysql

mysql> 
9、为root用户设置密码
[root@192 /]/application/mysql/bin/mysqladmin -u root password '123456'
10、问题解决
10.1 cmake 的时候报错 Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
解决方案:
 第一步:安装 yum -y install ncurses-devel 
 第二步:删除CMakeCache.txt通过find命令找到所有CMakeCache.txt文档的位置, 然后全部删除: 
 	#find / -name CMakeCache.txt 
全部删除后再重新cmake就OK了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值