CentOS 7.4 数据库的安装

1:数据库的安装
[root@huboxuexi ~]# groupadd mysql
[root@huboxuexi ~]# useradd mysql -g mysql -M -s /sbin/nologin
[root@huboxuexi ~]# id mysql
uid=1000(mysql) gid=1000(mysql) ื้=1000(mysql)
[root@apache httpd-2.2.34]# useradd mysql -g mysql -m -s /sbin/nologin
[root@apache httpd-2.2.34]# cd /home/hubo/tools/
-bash: cd: /home/hubo/tools/: ?????????
[root@apache httpd-2.2.34]# cd /home/hubo/
[root@apache hubo]# ls
httpd-2.2.34  httpd-2.2.34.tar.gz
[root@apache hubo]# mkdir tools/
[root@apache hubo]# cd tools/
[root@apache tools]# ls
mysql-5.5.32.tar.gz
[root@apache tools]# tar xf mysql-5.5.32.tar.gz 
[root@apache tools]# ls
mysql-5.5.32  mysql-5.5.32.tar.gz
[root@apache tools]# cd mysql-5.5.32/
[root@apache mysql-5.5.32]# ls
BUILD           cmd-line-utils   Docs                libmysql     mysys      scripts     strings        vio
BUILD-CMAKE     config.h.cmake   extra               libmysqld    packaging  sql         support-files  win
client          configure.cmake  include             libservices  plugin     sql-bench   tests          zlib
cmake           COPYING          INSTALL-SOURCE      man          README     sql-common  unittest
CMakeLists.txt  dbug             INSTALL-WIN-SOURCE  mysql-test   regex      storage     VERSION


1.3 安装相关包
1.3.1 cmake软件
cd /home/hubo/tools/
tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure
#CMake has bootstrapped.  Now run gmake.
gmake
gmake install
cd ../


1.3.2 依赖包
yum install ncurses-devel -y
yum install gcc-c++


1.4 开始安装mysql
1.4.1 创建用户和组
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql


1.4.2 解压编译MySQL
tar zxf 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


#-- Build files have been written to: /home/oldboy/tools/mysql-5.5.32
提示,编译时可配置的选项很多,具体可参考结尾附录或官方文档:
make
#[100%] Built target my_safe_process
make install
ln -s /application/mysql-5.5.32/ /application/mysql
如果上述操作未出现错误,则MySQL5.5.32软件cmake方式的安装就算成功了
[root@apache mysql-5.5.32]# echo $?
0

安装成功



2:Mysql配置文件
初始化
[root@apache-dav1 tools]# ls mysql-5.5.32/support-files/my*.cnf
mysql-5.5.32/support-files/my-huge.cnf             mysql-5.5.32/support-files/my-medium.cnf
mysql-5.5.32/support-files/my-innodb-heavy-4G.cnf  mysql-5.5.32/support-files/my-small.cnf
mysql-5.5.32/support-files/my-large.cnf
[root@apache-dav1 tools]# cd mysql-5.5.32/support-files/
[root@apache-dav1 support-files]# cp my-small.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
创建存放数据库的文件的地方
[root@apache-dav1 support-files]# mkdir /application/mysql/data -p
授权
[root@apache-dav1 support-files]# chown -R mysql.mysql /application/mysql/
[root@apache-dav1 ~]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/appl
ication/mysql/data/ --user=mysqlInstalling 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 apache-dav1 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!
有这么几个文件
[root@apache-dav1 mysql-test]# ll /application/mysql/data
总用量 8
drwx------  2 mysql root  4096 11月 20 11:04 mysql
drwx------  2 mysql mysql 4096 11月 20 11:04 performance_schema
drwxr-xr-x. 2 mysql mysql   20 11月 19 19:22 test



启动数据库
拷贝到/etc/init.d/mysqld
[root@apache-dav1 support-files]# cp mysql.server /etc/init.d/mysqld
添加到chkconfig管理
[root@apache-dav1 support-files]# chkconfig --add mysqld
开机自启动
[root@apache-dav1 support-files]# chkconfig mysqld on
授权
[root@apache-dav1 support-files]# chmod +x /etc/init.d/mysqld 
启动
[root@apache-dav1 support-files]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
进入数据库成功
[root@apache-dav1 support-files]# /application//mysql/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.32 Source distribution


Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> 


MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.01 sec)


MySQL [(none)]>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值