温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Linux WEB服务器搭建-MySql篇

发布时间:2020-07-21 00:44:24 来源:网络 阅读:432 作者:tom_tuwei 栏目:MySQL数据库

采用源码安装,可以根据实际生产环境加入一些参数,提升mysql性能

mysql官网https://www.mysql.com/

本文采用5.1版本尽心安装说明,后面版本如5.5安装方法会有些不一样,在公司的一些生产环境中也有用到

5.1版本mysql。

下载mysql源码

解压tar zxf mysql-5.1.72.tar.gz


cd  mysql-5.1.72


配置

./configure --prefix=/usr/local/mysql \

--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \

--localstatedir=/usr/local/mysql/data\    

--enable-assemble \

--enable-thread-safe-client \

--with-mysqld-user=mysql \

--with-big-tables \

--with-pthread \

--with-extra-charsets=complex \

--with-readline \

--with-ssl \

--with-mysqld-ldflags=-all-static \

--with-client-ldflags=-all-static

[root@backupserver mysql-5.1.72]# ./configure --help  查看具体的配置参数


make&&make install

这里采用开发测试模板

/bin/cp support-files/my-small.cnf   /etc/my.cnf

创建数据库文件

mkdir -p /usr/local/mysql/data

chown -R mysql /usr/local/mysql授权mysql用户可以访问mysql目录

/usr/local/mysql/bin/mysql_install_db --user=mysql安装mysql数据库文件

安装完后会有一些相关说明,如如何启动等等。

安装安装说明方法启动mysql

/usr/local/mysql/bin/mysqld_safe/usr/local/mysql/bin/mysqld_safe &    &表示后台运行

为了更方便的启动mysql,可以将mysql加到全局变量中

将mysql加到全局变量中echo 'export PATH=$PATH:/usr/local/mysql/bin'>>/etc/profile

source /etc/profile

执行mysql进入数据库

[root@backupserver mysql-5.1.72]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.1.72 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.



配置/etc/init.d/mysqld启动mysql

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

chmod 700 /etc/init.d/mysqld 授权,

将mysql服务加到开机启动 

[root@backupserver mysql-5.1.72]# chkconfig --add mysqld

[root@backupserver mysql-5.1.72]# chkconfig mysqld  on

mysql进入数据库

设置密码set password for root@localhost=PASSWORD('123456');

后续采用mysql -uroot -p形式进入mysql数据库


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI