Java学习笔记——Linux下安装配置MySQL
山重水复疑无路,柳暗花明又一村
——游山西村
系统:Ubuntu 16.04LTS
1\官网下载mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
2\建立工作组:
$su
#groupadd mysql
#useradd -r -g mysql mysql
3\创建目录
#mkdir /usr/local/mysql
#mkdir /usr/local/mysql/data
4\解压mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz,并拷贝至/usr/local/mysql
#tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
#cp -r /home/jieyamulu/mysql-5.7.18-linux-glibc2.5-x86_64/* /usr/local/mysql
5\修改mysql用户对mysql以下及其子文件夹以下文件的权限,修改后可使用ll查看权限
root@Ice-***:/usr/local# chown -R mysql:mysql mysql
root@Ice-***:/usr/local# ll
总用量 44
drwxr-xr-x 11 root root 4096 5月 19 07:39 ./
drwxr-xr-x 11 root root 4096 2月 16 04:30 ../
drwxr-xr-x 2 root root 4096 2月 16 04:19 bin/
drwxr-xr-x 2 root root 4096 2月 16 04:19 etc/
drwxr-xr-x 2 root root 4096 2月 16 04:19 games/
drwxr-xr-x 2 root root 4096 2月 16 04:19 include/
drwxr-xr-x 4 root root 4096 2月 16 04:23 lib/
lrwxrwxrwx 1 root root 9 3月 29 14:11 man -> share/man/
drwxr-xr-x 10 mysql mysql 4096 5月 19 07:48 mysql/
drwxr-xr-x 2 root root 4096 2月 16 04:19 sbin/
drwxr-xr-x 8 root root 4096 2月 16 04:34 share/
drwxr-xr-x 2 root root 4096 2月 16 04:19 src/
root@Ice-***:/usr/local# cd mysql/
root@Ice-***:/usr/local/mysql# ll
总用量 64
drwxr-xr-x 10 mysql mysql 4096 5月 19 07:48 ./
drwxr-xr-x 11 root root 4096 5月 19 07:39 ../
drwxr-xr-x 2 mysql mysql 4096 5月 19 07:48 bin/
-rw-r--r-- 1 mysql mysql 17987 5月 19 07:48 COPYING
drwxr-xr-x 2 mysql mysql 4096 5月 19 07:41 data/
drwxr-xr-x 2 mysql mysql 4096 5月 19 07:48 docs/
drwxr-xr-x 3 mysql mysql 4096 5月 19 07:48 include/
drwxr-xr-x 5 mysql mysql 4096 5月 19 07:48 lib/
drwxr-xr-x 4 mysql mysql 4096 5月 19 07:48 man/
-rw-r--r-- 1 mysql mysql 2478 5月 19 07:48 README
drwxr-xr-x 28 mysql mysql 4096 5月 19 07:48 share/
drwxr-xr-x 2 mysql mysql 4096 5月 19 07:48 support-files/
6\修改(或新建)/etc/my.cnf 配置文件
root@Ice-***:/usr/local/mysql# vim /etc/my.cnf
[mysqld] basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data
:wq
7\最关键的初始化
# cd /usr/local/mysql/
root@Ice-***:/usr/local/mysql# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2017-05-19T00:15:46.529420Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-05-19T00:15:47.066125Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-05-19T00:15:47.213711Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-05-19T00:15:47.286951Z 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: 4e958344-3c28-11e7-8334-c8d3ffd2db82.
2017-05-19T00:15:47.292857Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-05-19T00:15:47.294758Z 1 [Note] A temporary password is generated for root@localhost: YjaotQk*2ew4
初始密码要记住
这里可能会出现很多问题,比如:
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
缺少依赖关系包
解决方法:sudo apt-get install libaio-dev
还有可能是之前步骤不对导致了操作data文件的权限不够等等.按照步骤来,缺少什么装什么(有提示),到了这里应该就初始化成功了,那几个Warning,值得注意的是Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.有时间可以查下是怎么回事,这条忽略也没影响.
8\不要着急启动,现在还启动不了.执行代码,将mysql下除了data文件夹外的文件变为root权限
root@Ice-***:/usr/local/mysql# chown -R root .
root@Ice-***:/usr/local/mysql# chown -R mysql data
9\启动
root@Ice-***:/usr/local/mysql# bin/mysqld_safe --user=mysql &
敲回车
root@Ice-***:/usr/local/mysql# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18
Copyright (c) 2000, 2017, 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>
10\重置密码
mysql> SET PASSWORD = PASSWORD('newpasswd');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> quit
Bye
11\设置开机启动
root@Ice-***:/usr/local/mysql# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
root@Ice-***:/usr/local/mysql# chmod 755 /etc/init.d/mysqld
12\安装mysql-server 和 mysql-client
root@Ice-***:~# apt-get install mysql-server
root@Ice-***:~# apt-get install mysql-client
root@Ice-***:~# apt-get install libmysqlclient-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)
解决办法:
1.$ sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_old //现将info文件夹更名
2.$ sudo mkdir /var/lib/dpkg/info //再新建一个新的info文件夹
3.$ sudo apt-get update,
$ apt-get -f install //修复依赖树
4.$ sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old //执行完上一步操作后会在新的info文件夹下生成一些文件,现将这些文件全部移到info_old文件夹下
5.$ sudo rm -rf /var/lib/dpkg/info //把自己新建的info文件夹删掉
6.$ sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info //把以前的info文件夹重新改回名字
最后,如果是Ubuntu系统可能无法向表中插入汉字,无法从表中查询汉字..
解决办法:
关闭数据库服务
service mysql stop
~$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
在[mysqld]下添加一行character_set_server=utf8
配置文件选段:
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
character_set_server=utf8 就是这一行,原来是没有的,要手动添加!
skip-external-locking
#
将上述文件拷贝至/etc/mysql/my.cnf
~$ sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf
重启数据库服务
~$ /etc/init.d/mysql restart
如果查看字符集能得到如下结果就说明成功了.
mysql> show variables like 'collation_%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
Java学习笔记——Linux下安装配置MySQL的更多相关文章
- Java学习笔记——Linux下安装配置tomcat
朝辞白帝彩云间,千里江陵一日还. 两岸猿声啼不住,轻舟已过万重山. ——早发白帝城 首先需要安装配置JDK,这里简单回顾下.Linux下用root身份在/opt/文件夹下创建jvm文件夹,然后使用ta ...
- (转载)Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记
Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记 Linux下配LMAP环境,花了我好几天的时间.之前没有配置过,网上的安装资料比较混乱,加上我用的版本问题,安装过程 ...
- PHP学习笔记----IIS7下安装配置php环境
原文:PHP学习笔记----IIS7下安装配置php环境 Php如何安装 Php版本的选择 Php在windows下的(php5.4.7)有两种版本: VC9 x86 Non Thread Safe ...
- Linux下安装配置MySQL
一.删除原来的MySQL 在安装前要先确定系统是否已经安装了其他版本的MySQL,如已安装其他版本的MySQL,需先删除后再安装新版本. 1. 执行yum命令,删除MySQL的lib库,服务文件 yu ...
- redis学习之一 - linux下安装配置
Content 0.序 1.如何安装? 2.配置参数及其意义 3.设为linux服务 0.序 本文主要是记录Redis在 Centos下的安装配置 .文中如无特别说明.表示redis-3.2.10代码 ...
- [学习笔记]Ubuntu下安装配置SQLSERVER2017
摘要自微软官网: https://docs.microsoft.com/zh-cn/sql/linux/quickstart-install-connect-ubuntu 安装步骤: 1. 导入公共秘 ...
- Python学习笔记-Linux下安装Python
Linux系统CentOS 1.安装依赖组件 yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel s ...
- Linux下安装配置MySQL5.7服务器
Linux下安装配置MySQL服务器 一.安装环境 ============ OS:centos6.8 MySQL:mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz ...
- Linux下安装配置与使用MySQL数据库
Linux下安装配置与使用MySQL数据库 在Linux下安装做开发时往往少不了要使用到MySQL数据库,下面就Linux系统为例讲解一下,如何安装MySQL数据库,如何启用/停.止MySQL服务,如 ...
随机推荐
- Mybatis基础学习(一)—初识MyBatis
一.MyBatis是什么? MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google co ...
- Windows安装mysql-python提示:error: Microsoft Visual C++ 9.0 is required
Windows安装mysql-python提示:error: Microsoft Visual C++ 9.0 is required,Get it from http://aka.ms/vcpyth ...
- Linux Smaba服务器配置
Linux系统默认已经安装了Samba,但是没有安装Samba服务: 1,先查看安装情况:rpm -qa|grep samba 根据系统的安装情况选择下载或者通过光驱安装所缺的rpm包. 我的安装情况 ...
- maven私服搭建nexus介绍(二)
1.各个仓库介绍 Hosted:宿主仓库 主要放本公司开发的SNAPSHOTS测试版本,RELEASES正式发行版.合作公司第三方的jar包. Proxy:代理仓库 代理中央仓库:代理Apache下测 ...
- 转账示例(二):service层面实现(本例采用QueryRunner来执行sql语句,数据源为C3P0)
缺点:Service层面把Dao层面的开启事务操作完成了1.自行创建C3P0Uti,account数据库,导入Jar包 2.Dao层面 接口: package com.learning.dao; im ...
- ubuntu12.04.5安装openssh-server所引发的血案
刚安装好的ubuntu12.04.5在安装openssh-server之后,安装其他软件都安装不了,如下: root@ubuntu:/home/lancer/software/ssh# apt-get ...
- JS Dom节点操作demo!
通过黑马课程的学习,在这里分享一个js Dom中节点操作的小练习 需求:使用js创建一个4*3的表格table. onload = function(){ function c(tagName){ r ...
- 【uwp】浅谈China Daily中数据同步到One Drive的实现
新版China Daily与旧版相比新增了数据同步的功能,那这个功能具体是如何实现的呢,现在让我们来一起看看. 1.注册应用 开发者中心的应用注册就不用多说了(https://developer.mi ...
- IIC模块TestBench的书写方法
今天在看黑金AX309FPGA开发板自带教程中的EEPROM那一章,考虑如何写其中iic_com模块的TestBench,难点在于1. 该模块存在一个inout型的端口信号:2. 时序较为复杂,不可能 ...
- JDK源码之PriorityQueue源码剖析
除特别注明外,本站所有文章均为原创,转载请注明地址 一.优先队列的应用 优先队列在程序开发中屡见不鲜,比如操作系统在进行进程调度时一种可行的算法是使用优先队列,当一个新的进程被fork()出来后,首先 ...