mysql--cmake安裝(2)

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故障解決

mysql-cmake方式安裝(2)

 

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"

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章