龙空技术网

mysql-cmake方式安装(2)

京城莹莹 133

前言:

此刻姐妹们对“mysql cmake”大约比较关注,看官们都想要剖析一些“mysql cmake”的相关文章。那么小编在网络上搜集了一些关于“mysql cmake””的相关文章,希望朋友们能喜欢,小伙伴们快快来学习一下吧!

1.先安装相关工具依赖包

yum -y install lrzsz

yum install gcc

yum install gcc-c++

yum install ncurses-devel -y

yum install bison

2.再安装cmake

cd /usr/local/src/

上传 cmake 包和mysql.tar.gz包

tar xf cmake-2.8.8.tar.gz

cd cmake-2.8.8

./configure

gmake

gmake install

cd ../

3.安装mysql

groupadd mysql 添加用户和组

useradd mysql -s /sbin/nologin -M -g mysql

解压编译mysql

tar xf mysql-5.5.32.tar.gz

cd mysql-5.5.32

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \

-DMYSQL_DATADIR=/application/mysql-5.5.32/data \

-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/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

接下来

make && make install

安装至此,没报错就是安装成功。

创建链接 ln -s /application/mysql-5.5.32/ /application/mysql

4. 选择配置文件,测试环境选小的,生产环境可以根据硬件选择,例如my-innodb-heavy-4G.cnf

cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf

5.配置环境变量

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

tail -l /etc/profile

source /etc/profile

echo $PATH

6. ll /application/mysql/data

chown -R mysql.mysql /application/mysql/data/

chmod -R 777 /tmp/

cd /application/mysql/scripts/

./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

会有以下 提示信息

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 hdp4 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.此时在script路径下运行 mysql发现没有这个命令

cd /usr/local/src/mysql-5.5.32

cp support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

/etc/init.d/mysqld start (会提示启动成功)

mysql

8.登陆mysql故障解决

9.修改root用户密码 /application/mysql//bin/mysqladmin -u root password '123456'

10.设置远程连接

use mysql;

update user set host ="%" where user ="root";

当报错ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 错误,直接查root当前的host属性,

select host from user where user = 'root';

若host中已经存在%了,直接运行以下sql,

flush privileges;

11. 或者干脆全部删除,添加额外管理员

delete from mysql.user;

grant all privileges on *.* to system@'localhost' identified by '123456' with grant option.

(with grant option 保证该管理员system也可以设置用户,等同于root.)

12.设置开机自启动

chkconfig mysqld on

chkconfig --list mysqld

13.修改linux字符集

vi etc/sysconfig/i18n

LANG="zh_CN.UTF-8"

标签: #mysql cmake