linux安装mysql详细步骤

Linux自带的Mysql已经卸载干净,安装前要检查是否有系统自带的Mysql软件。

linux系统版本: CentOS 6.6  64位

安装源文件版本:mysql-cluster-gpl-7.6.11-linux-glibc2.12-x86_64.tar.gz(该包含有NDB和Mysql软件)

mysql安装位置:/software/mysql  --一般情况下放在/usr/local/mysql下

数据库文件数据位置:/data/mysql

1.创建安装路径和数据文件存储路径

[[email protected] ~]# mkdir -p /software/mysql
[[email protected] ~]# mkdir -p /data/mysql

2.将安装包上传到安装路径并进行解压

[[email protected] ~]# mv /package/mysql-cluster-gpl-7.6.11-linux-glibc2.12-x86_64.tar.gz /software/mysql

[[email protected] software]# chown -R mysql.mysql mysql
[[email protected] software]# ll
total 894336
-rwxrwxrwx. 1 mysql mysql 915792308 Sep 7 14:58 mysql

[[email protected] software]#tar -zvxf mysql

3.创建Mysql用户和用户组,并进行授权

[[email protected] ~]# groupadd mysql
[[email protected] ~]# useradd -r -g mysql mysql

[[email protected] ~]# chown -R mysql.mysql /software/mysql/
[[email protected] ~]# chown -R mysql.mysql /data/mysql/
[[email protected] ~]# chown -R mysql /software/mysql/
[[email protected] ~]# chown -R mysql /data/mysql/

4.更改mysql安装文件夹mysql/的权限

[[email protected] ~]#chmod -R 755 /software/mysql/

5.安装依赖包libaio

5.1 查询是否暗转libaio依赖包

[[email protected] ~]# yum search libaio
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
===================================== N/S Matched: libaio =====================================
libaio.x86_64 : Linux-native asynchronous I/O access library

Name and summary matches only, use "search all" for everything.

如果没安装,可以用下面命令安装

[[email protected] ~]# #yum install libaio*

6.初始化mysql命令

[[email protected] bin]# pwd
/software/mysql/mysql/bin
[[email protected] bin]# ./mysqld --user=mysql --basedir=/software/mysql --datadir=/data/mysql --initialize
2019-11-23T04:05:05.570200Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-11-23T04:05:05.581420Z 0 [ERROR] Can‘t find error-message file ‘/software/mysql/share/errmsg.sys‘. Check error-message file location and ‘lc-messages-dir‘ configuration directive.
2019-11-23T04:05:07.993304Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-11-23T04:05:08.487409Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-11-23T04:05:08.690798Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 703b982c-0da6-11ea-a729-000c2929e347.
2019-11-23T04:05:08.703102Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2019-11-23T04:05:08.722606Z 1 [Note] A temporary password is generated for [email protected]: Pubi)p0+okYo

注意标红部分为初始化密码

7.修改mysql配置文件,用于启动mysql服务

修改前:

# Set some defaults
mysqld_pid_file_path=
if test -z "$basedir"
then
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
if test -z "$datadir"
then
datadir=/usr/local/mysql/data
fi
sbindir=/usr/local/mysql/bin
libexecdir=/usr/local/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi

修改后

# Set some defaults
mysqld_pid_file_path=
if test -z "$basedir"
then
basedir=/software/mysql
bindir=/software/mysql/bin
if test -z "$datadir"
then
datadir=/data/mysql/
fi
sbindir=/software/mysql/bin
libexecdir=/software/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi

添加服务

[[email protected] bin]# cp /software/mysql/mysql/support-files/mysql.server /etc/init.d/mysqld
[[email protected] bin]# chmod 775 /etc/init.d/mysqld

8.修改my.cnf配置文件,将下面内容覆盖到my.cnf文件

[client]
no-beep
socket =/software/mysql/mysql.sock
# pipe
# socket=0.0
port=3306
[mysql]
default-character-set=utf8
[mysqld]
basedir=/software/mysql
datadir=/data/mysql
port=3306
pid-file=/software/mysql/mysqld.pid
#skip-grant-tables
skip-name-resolve
socket = /software/mysql/mysql.sock
character-set-server=utf8
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true
# Server Id.
server-id=1
max_connections=2000
query_cache_size=0
table_open_cache=2000
tmp_table_size=246M
thread_cache_size=300
#限定用于每个数据库线程的栈大小。默认设置足以满足大多数应用
thread_stack = 192k
key_buffer_size=512M
read_buffer_size=4M
read_rnd_buffer_size=32M
innodb_data_home_dir = /data/mysql
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=16M
innodb_buffer_pool_size=256M
innodb_log_file_size=128M
innodb_thread_concurrency=128
innodb_autoextend_increment=1000
innodb_buffer_pool_instances=8
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=300
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0
back_log=80
flush_time=0
join_buffer_size=128M
max_allowed_packet=1024M
max_connect_errors=2000
open_files_limit=4161
query_cache_type=0
sort_buffer_size=32M
table_definition_cache=1400
binlog_row_event_max_size=8K
sync_master_info=10000
sync_relay_log=10000
sync_relay_log_info=10000
#批量插入数据缓存大小,可以有效提高插入效率,默认为8M
bulk_insert_buffer_size = 64M
interactive_timeout = 120
wait_timeout = 120
log-bin-trust-function-creators=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

9启动mysql服务

[[email protected] software]# /etc/init.d/mysqld start
Starting MySQL.Logging to ‘/data/mysql/db.err‘.
...... SUCCESS!
[[email protected] software]# service mysqld status
SUCCESS! MySQL running (6138)

10.登录Mysql

10.1建立软连接生产mysql命令

[[email protected] ~]# ln -s /software/mysql/bin/mysql mysql

[[email protected] ~]# ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.27-ndb-7.6.11-cluster-gpl

Copyright (c) 2000, 2019, 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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password=password(‘root‘);
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> grant all privileges on *.* to [email protected]‘%‘ identified by ‘root‘;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)

10.2修改/software/mysql/bin/mysqld_safe文件

将文件里/usr/local/mysql改为/software/mysql

原文地址:https://www.cnblogs.com/guipeng/p/11917044.html

时间: 2024-11-09 18:08:22

linux安装mysql详细步骤的相关文章

Mac 安装Mysql 详细步骤方法

Mac 安装Mysql 详细步骤方法 第一步: 登陆官网:https://www.mysql.com 进入, 点击下方的DOWNLOADS -> Community->MySQL Community Server下载dgm文件,选择不登陆直接下载,下载后常规安装,设置自己的mysql密码 记住密码 第二步: 安装好mysql后直接终端是不可以运行的,可以在偏好设置里面启动以及停止mysql服务 第三步: 配置路径打开终端 输入:vim ~/.bash_profile 在图中添加 mysql路径

ubuntu16.04下安装mysql详细步骤

我们打开Xshell,通过如入命令安装mysql 依次输入这三条命令; sudo apt-get install mysql-server sudo apt install mysql-client sudo apt install libmysqlclient-dev 弄完一条再弄一条.如下所示:如入命令后再输入Y 然后回车就自动安装 第二条和第三条类似这样输入看提示进行安装.在安装过程需要设置数据库密码(在键盘输入数字时不要在右边的1234567890上按数字,那里的0代表ins,要在键盘上

Linux安装JDK详细步骤(rpm方式)

Linux安装JDK 1. 先从网上下载jdk(jdk-6u32-linux-i586-rpm) ,下载后放在/home目录中,当然其它地方也行. 进入安装目录 #cd /home #cp jdk-6u32-linux-i586-rpm /usr/local #cd /usr/local 给所有用户添加可执行的权限 #chmod +x jdk-6u32-linux-i586-rpm.bin #./jdk-6u32-linux-i586-rpm.bin 此时会生成文件jdk-6u32-linux-

Linux安装JDK详细步骤

1.先从网上下载JDK(jdk-1_5_0_02-linux-i586.rpm). 推荐SUN的官方网站www.sun.com,下载后放在/home目录中,当然其它地方也行.注意:*.rpm包是Linux下的可安装文件,而*.tar.gz包是Linux下的压缩文件,一般包含的是源代码. 进入安装目录 #cd /home #cp jdk-1_5_0_02-linux-i586.rpm /usr/local #cd /usr/local 给所有用户添加可执行的权限 #chmod +x jdk-1_5

Linux安装phpMyAdmin详细步骤

phpMyAdmin 3.x版本要求php5.2以上,mysql5.0以上,对号入座 phpMyAdmin是一种MySQL的管理工具,它直接从web上去管理MySQL 1:上传phpMyAdmin-3.4.5-all-languages.tar.gz 2:解压 # tar zxvf phpMyAdmin-3.4.5-all-languages.tar.gz 3:重命名 # mv  phpMyAdmin-3.4.5-all-languages.tar.gz 安装完成后,可在/usr/share目录

window下安装mysql详细步骤

1.下载安装包 打开mysql官网下载页面:http://dev.mysql.com/downloads/mysql/ 1.选择相应的版本和平台 2.mysql配置 打开刚刚解压的文件夹F:\mysql-5.7.25-winx64\mysql-5.7.25-winx64,发现里面有my-default.ini配置文件,这个是默认的配置文件,复制一个自己的改名字为my.ini 编辑my.ini配置以下基本信息: [mysql] # 设置mysql客户端默认字符集 default-character

关于centos7如何二进制安装mysql,详细步骤!

第一步:首先在mariadb官网下载mariadb编译好的二进制压缩包https://downloads.mariadb.org/ 第二步:解压下载好的mariadb压缩包,由于下载好的是别人编译好的二进制压缩包,所以解压路径是有规定的必须在 "/usr/local/" 下,若是自己源码编译可以自行选择解压目录! tar xvf mariadb-102.23-linux-x86_64.tar.gz -C /usr/local/ · 第三步:由于解压好的文件夹(mariadb-10.2.

LINUX安装nginx详细步骤

1.安装依赖包 //一键安装上面四个依赖yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel2.下载并解压安装包 //创建一个文件夹cd /usr/localmkdir nginxcd nginx//下载tar包wget http://nginx.org/download/nginx-1.13.7.tar.gztar -xvf nginx-1.13.7.tar.g3.安装nginx //进入nginx目录cd /u

在Linux(CentOS)上安装MySql详细记录

前记:  毕业两年了,前两天换了份工作,由以前的传统行业跳到了互联网行业.之前的公司一直在用WinServer2003+Tomcat+SqlServer/Oracle这套部署环境.对于Linux+Tomcat(或其他容器)+Mysql这套之前没用用过.所以利用这周末的我在阿里云上49元搞了个linux(centos 64位)的服务器. 刚开始先装了JDK1.6,安装了Tomcat6.0.这过程中没有遇到太大的问题, 小问题也google一下就解决了.而周六晚上开始安装Mysql,于是到今天下午为