资讯专栏INFORMATION COLUMN

MySQL安装部署

IT那活儿 / 984人阅读
MySQL安装部署
点击上方“IT那活儿”公众号,关注后了解更多内容,不管IT什么活儿,干就完了!!!
1. 创建mysql用户
groupadd mysql
useradd -g mysql mysql
2. 部署MySQL软件
mkdir /data
chown -R mysql:mysql   /data
cd
mv mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz /data/mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz

mkdir -p /software/mysql
chown -R mysql:mysql /software
cd /software/mysql
tar zxvf /data/mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
3. 创建软链接
cd /usr/local/
unlink mysql
ln -s /software/mysql-5.7.30-linux-glibc2.12-x86_64 mysql
chown -R mysql:mysql mysql
4. 创建基本目录
mkdir /data/mysql
mkdir /data/mysql/mysql_3306
cd /data/mysql/mysql_3306/
mkdir data
mkdir logs
mkdir tmp
chown -R mysql:mysql /data/mysql/mysql_3306
5. 创建my.cnf
vi /etc/my.cnf

[client]
port = 3306
socket = /tmp/mysql3306.sock

[mysql]
#prompt="(u:HOSTNAME:)[d]> "
prompt="u@h R:m:s [d]> "
no-auto-rehash

[mysqld]
user = mysql
port = 3306
socket = /tmp/mysql3306.sock
basedir = /usr/local/mysql
datadir = /data/mysql/mysql_3306/data
character-set-server = utf8
back_log = 103
slow_query_log = 1
slow_query_log_file = /data/mysql/mysql_3306/data/slow.log
log-error = /data/mysql/mysql_3306/data/error.log
long_query_time = 0.1
server-id = 813306
log-bin = /data/mysql/mysql_3306/logs/log-bin
sync_binlog = 1
binlog_cache_size = 4M
binlog_format = row
relay_log_recovery = 1

transaction_isolation = REPEATABLE-READ
#innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 5734M
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_data_file_path = ibdata1:1024M;ibdata2:1024M;ibdata3:1024M:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 16M
innodb_log_file_size = 2G
innodb_log_files_in_group = 2
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_file_per_table = 1
innodb_locks_unsafe_for_binlog = 0


cd /usr/local/mysql
./bin/mysqld --initialize-insecure
6. 数据库实例初始化
cd /usr/local/mysql
[root@master01 mysql]# pwd
/usr/local/mysql

[root@master01 mysql]#
[root@master01 mysql]# <+++++++++++++无任何回显

[root@Mysql01 mysql]# ./bin/mysqld --initialize-insecure
#–initialize-insecure,不需要密码即可进入

[root@Mysql01 mysql]# ./bin/mysqld --initialize
./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@Mysql01 mysql]#
[root@Mysql01 mysql]#

[root@Mysql01 mysql]# yum -y install libaio.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
epel | 5.3 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 973 kB 00:00:00
(2/2): epel/x86_64/primary_db | 6.7 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================================
Installing:
libaio x86_64 0.3.109-13.el7 base 24 k

Transaction Summary
=================================================================================================================================================================================================================================
Install 1 Package

Total download size: 24 k
Installed size: 38 k
Downloading packages:
libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libaio-0.3.109-13.el7.x86_64 1/1
Verifying : libaio-0.3.109-13.el7.x86_64 1/1

Installed:
libaio.x86_64 0:0.3.109-13.el7

Complete!
[root@Mysql01 mysql]#
[root@Mysql01 mysql]#
[root@Mysql01 mysql]#
7. 创建启动脚本
cd /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysql
echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
source /etc/profile



====
[root@master01 ~]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use systemctl list-unit-files.
To see services enabled on particular target use
systemctl list-dependencies [target].
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@master01 ~]# chkconfig --add mysql.server
error reading information on service mysql.server: No such file or directory
[root@master01 ~]#
[root@master01 ~]#
[root@master01 ~]# chkconfig --add mysql
[root@master01 ~]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use systemctl list-unit-files.
To see services enabled on particular target use
systemctl list-dependencies [target].
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@master01 ~]#

=====
8. 启动和关闭数据库
service mysql start |stop|restart
9. 密码来自error.log 文件
cat /data/mysql/mysql_3306/data/error.log |grep "password"

2017-11-01T07:31:33.932297Z 1 [Note] A temporary password is generated for root@localhost: XX41vxuK;=!q

mysql -S /tmp/mysql3306.sock -uroot -p
首次登陆需要修改root密码:
alter user root@localhost identified by abcd1234;
flush privileges;


本文作者:张德桥(上海新炬王翦团队)

本文来源:“IT那活儿”公众号

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/129340.html

相关文章

  • 云服务器 ECS 建站教程:在ECS上部署数据库

    摘要:在阿里云平台上,可通过自带的镜像市场实现一键部署系统的数据库,完美解决耗时长部署易出错的缺陷。操作步骤登录云服务器管理控制台。单击左侧导航中的云服务器创建实例。在ECS上部署数据库 数据库是依照某种数据模型组织起来并存放二级存储器中的数据集合。这种数据集合具有如下特点:尽可能不重复,以最优方式为某个特定组织的多种应用服务,其数据结构独立于使用它的应用程序,对数据的增、删、改和检索由统一软件进...

    stefan 评论0 收藏0
  • Ubuntu下部署Django应用

    摘要:配置这个启动其他方式安装七牛云由于网站的静态存储要用七牛云,在运行程序前要安装否则报错没有的方法。七牛云安装前注意安装的版本,我被坑过一次,写程序时是版本,部署时都了,接口全都不一样。还有推荐下这篇来自的部署实例 以下所有代码中的操作都需要在命令行运行 安装mysql apt-get update apt-get install mysql-server mysql-client 根据...

    tinysun1234 评论0 收藏0
  • windows一键部署java项目

    摘要:一的函数,在代码块中,可以自定义很多功能来实现自定义的开发,具体可以参考在线的文档二需要用脚本配置环境变量,安装部署,安装部署。 windows一键部署java项目 因为公司需求,要在windows的环境上做一键部署启动java项目,同时还要支持从安装界面动态修改配置文件的IP地址。就像安装软件一样将jdk,tomcat,mysql,influxdb,nginx安装并配置到系统上,顺便...

    xbynet 评论0 收藏0

发表评论

0条评论

IT那活儿

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<