MySQL单实例的安装配置指南 5.1版本

MySQL单实例的安装配置指南
MySQL是开源的关系型数据库产品。
1、建立MySQL数据库账号。
#以root身份登录到linux系统,然后执行如下命令。
[root@c601 ~]# groupadd mysql
[root@c601 ~]# useradd -s /sbin/nologin -g mysql -M mysql
[root@c601 ~]# tail -1 /etc/passwd
mysql:x:503:503::/home/mysql:/sbin/nologin
#从mysql官网下载编译版本的安装包,rz上传版本包。
[root@c601 tools]# ll mysql-5.1.62.tar.gz 
-rw-r--r-- 1 root root 24503313 Feb 11 21:34 mysql-5.1.62.tar.gz
[root@c601 tools]# tar xf mysql-5.1.62.tar.gz 
[root@c601 tools]# cd mysql-5.1.62
#解压、编译、安装mysql。
#编译参数如下:
./configure \
--prefix=/usr/local/mysql \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--localstatedir=/usr/local/mysql/data \
--enable-assembler \
--with-mysqld-ldflags=--all-static \
--with-client-ldflags=--all-static \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread
#编译、安装。
make && make install
PS:参数说明
./configure \
--prefix=/usr/local/mysql \  #指定mysql安装路径,默认为/usr/local
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \ #指定mysql socket文件存放目录
--localstatedir=/usr/local/mysql/data \ #设定MySQL的数据文件存放位置
--enable-assembler \          #允许使用汇编模式(性能优化)
--with-mysqld-ldflags=--all-static \  #服务器使用静态库(性能优化)
--with-client-ldflags=--all-static \ #客户端使用静态库(性能优化)
--enable-thread-safe-client \   #以线程的方式编译客户端
--with-mysqld-user=mysql \  #指定mysql运行的系统用户
--with-big-tables \ #支持大表,即使超过4GB
--without-debug \   #使用非debug模式
--with-pthread  #强制是哦那个pthread线程序库编译
#创建数据运行模式
[root@c601 mysql-5.1.62]# /bin/cp support-files/my-small.cnf /etc/my.cnf
[root@c601 mysql-5.1.62]# ll -l /etc/my.cnf
-rw-r--r--. 1 root root 2467 Feb 11 21:58 /etc/my.cnf
#创建数据库文件
[root@c601 mysql-5.1.62]# mkdir -p /usr/local/mysql/data
[root@c601 mysql-5.1.62]# chown -R mysql.mysql /usr/local/mysql
#初始化数据文件
[root@c601 mysql-5.1.62]# /usr/local/mysql/bin/mysql_install_db --user=mysql
PS:提示如下,提示很有用可以好好看看。
WARNING: The host 'c601.zte' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
180211 22:02:29 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
180211 22:02:29 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
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:


/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h c601.zte password 'new-password'


Alternatively you can run:
/usr/local/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 /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &


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


Please report any problems with the /usr/local/mysql/bin/mysqlbug script!
#启动mysql
[root@c601 mysql-5.1.62]# /usr/local/mysql/bin/mysqld_safe &
[root@c601 mysql-5.1.62]# netstat -lntup|grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      63891/mysqld   


PS:如果没起来可以查看错误日志。
[root@c601 mysql-5.1.62]# tail -10 /usr/local/mysql/data/c601.zte.err 


#配置mysql命令全局使用路径
[root@c601 mysql-5.1.62]# echo 'export PATH=$PATH:/usr/local/mysql/bin' >>/etc/profile
[root@c601 mysql-5.1.62]# source /etc/profile
(--测试--)使用mysql命令进入mysql(--测试--)
[root@c601 mysql-5.1.62]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.62 Source distribution


Copyright (c) 2000, 2011, 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> 


#配置/etc/init.d/mysqld start方式启动数据库
[root@c601 mysql-5.1.62]# cp support-files/mysql.server /etc/init.d/mysqld
[root@c601 mysql-5.1.62]# chmod 700 /etc/init.d/mysqld 
[root@c601 mysql-5.1.62]# ll /etc/init.d/mysqld 
-rwx------ 1 root root 12303 Feb 11 22:34 /etc/init.d/mysqld
(--测试--)重启mysql(--测试--)
[root@c601 mysql-5.1.62]# /etc/init.d/mysqld stop
Shutting down MySQL.180211 22:34:54 mysqld_safe mysqld from pid file /usr/local/mysql/data/c601.zte.pid ended
                                                           [  OK  ]
[1]+  Done                    /usr/local/mysql/bin/mysqld_safe
[root@c601 mysql-5.1.62]# /etc/init.d/mysqld start
Starting MySQL.                                            [  OK  ]
[root@c601 mysql-5.1.62]# netstat -lntup|grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      47866/mysqld   
###
#为mysql增加密码
[root@c601 mysql-5.1.62]# mysqladmin -uroot password 'zxin10'
#清理MySQL无用用户。
mysql> select user,host from mysql.user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
|      | c601.zte  |
| root | c601.zte  |
|      | localhost |
| root | localhost |
+------+-----------+
5 rows in set (0.00 sec)


mysql> drop user ""@c601.zte 
    -> ;
Query OK, 0 rows affected (0.00 sec)


mysql> drop user ""@localhost
    -> ;
Query OK, 0 rows affected (0.00 sec)


mysql> drop user "root"@c601.zte
    -> ;
Query OK, 0 rows affected (0.01 sec)


mysql> select user,host from mysql.user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
2 rows in set (0.00 sec)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值