# Copyright (c) 2014,2016,Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not,write to the Free Software
# Foundation,Inc.,51 Franklin St,Fifth Floor,Boston,MA 02110-1301 USA
#
# The MysqL Server configuration file.
#
# For explanations see
# http://dev.MysqL.com/doc/MysqL/en/server-system-variables.html
[client]
port = 3306
socket = /var/run/MysqLd/MysqLd.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_MysqLd]. Both versions are currently parsed.
[MysqLd_safe]
socket = /var/run/MysqLd/MysqLd.sock
nice = 0
[MysqLd]
character-set-server=utf8
lower_case_table_names=1
#
# * 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
datadir = /mnt/MysqL/
tmpdir = /var/tmp
lc-messages-dir = /usr/share/MysqL
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#
# * Fine Tuning
#
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/MysqL/MysqL.log
#general_log = 1
#
# Error log - should be very few entries.
#
#log_error = /var/log/MysqL/error.log
log_error = /mnt/log/MysqL/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/MysqL/MysqL-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave,see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/MysqL/MysqL-bin.log
log_bin = /mnt/log/MysqL/MysqL-bin.log
binlog_format = "MIXED"
#expire_logs_days = 3
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/MysqL/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual,too,if you want chroot!
# chroot = /var/lib/MysqL/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/MysqL/cacert.pem
# ssl-cert=/etc/MysqL/server-cert.pem
# ssl-key=/etc/MysqL/server-key.pem
[MysqLdump]
quick
quote-names
max_allowed_packet = 16M
[MysqL]
default-character-set=utf8
#no-auto-rehash # faster start of MysqL but no tab completition
[isamchk]
key_buffer = 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf',otherwise they'll be ignored.
#
!includedir /etc/MysqL/conf.d/
[MysqLd]
wait_timeout=31536000
interactive_timeout=31536000
如果之前安装过MysqL,请执行如下操作
-----------------------------------------------------------------
UBUNTU 彻底删除 MYSQL 然后重装 MYSQL
删除 MysqL
sudo apt-get autoremove --purge MysqL-server-5.0
sudo apt-get remove MysqL-server
sudo apt-get autoremove MysqL-server
sudo apt-get remove MysqL-common //这个很重要
上面的其实有一些是多余的。
清理残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
----------------------------------------------------------------------------
这里是正常的开始安装步骤:
1.在官网下载MysqL安装包
解压命令为:
tar –xvf MysqL-server_5.6.28-1ubuntu14.04_amd64.deb-bundle.tar
解压后得到一系列的.deb文件。依次为:
libMysqLclient18_5.6.28-1ubuntu14.04_amd64.deb
libMysqLclient-dev_5.6.28-1ubuntu14.04_amd64.deb
libMysqLd-dev_5.6.28-1ubuntu14.04_amd64.deb
MysqL-client_5.6.28-1ubuntu14.04_amd64.deb
MysqL-common_5.6.28-1ubuntu14.04_amd64.deb
MysqL-community-bench_5.6.28-1ubuntu14.04_amd64.deb
MysqL-community-client_5.6.28-1ubuntu14.04_amd64.deb
MysqL-community-server_5.6.28-1ubuntu14.04_amd64.deb
MysqL-community-source_5.6.28-1ubuntu14.04_amd64.deb
MysqL-community-test_5.6.28-1ubuntu14.04_amd64.deb
MysqL-server_5.6.28-1ubuntu14.04_amd64.deb
MysqL-testsuite_5.6.28-1ubuntu14.04_amd64.deb
3.安装文件
这里这些文件存在着依赖关系,如果一个一个安装,要安装顺序来安装:
sudo dpkg -i MysqL-common_5.6.28-1ubuntu14.04_amd64.deb
sudo dpkg -i libMysqLclient18_5.6.28-1ubuntu14.04_amd64.deb
sudo dpkg -i libMysqLclient-dev_5.6.28-1ubuntu14.04_amd64.deb
sudo dpkg -i libMysqLd-dev_5.6.28-1ubuntu14.04_amd64.deb
sudo dpkg -i MysqL-community-server_5.6.28-1ubuntu14.04_amd64.deb注意在安装MysqL-community-server会要求输入root账户密码
sudo dpkg -i MysqL-server_5.6.28-1ubuntu14.04_amd64.deb
到这里个人认为服务器应该可以使用了(未测试),但是MysqL命令还不能使用
sudo dpkg -i MysqL-community-client_5.6.28-1ubuntu14.04_amd64.deb
sudo dpkg -i MysqL-client_5.6.28-1ubuntu14.04_amd64.deb到这里,MysqL的安装完成
还有几个文件没有用,用处现在不知道
MysqL-community-bench_5.6.28-1ubuntu14.04_amd64.deb
MysqL-community-source_5.6.28-1ubuntu14.04_amd64.deb
MysqL-community-test_5.6.28-1ubuntu14.04_amd64.deb
MysqL-testsuite_5.6.28-1ubuntu14.04_amd64.deb
安装过程中可能会提示缺少依赖包,这里安装依赖包就好 比如:
这里安装一下 libmecab2 可能会在这出现输入数据库的密码界面
@H_333_301@
4.启动和停止MysqL服务命令
/etc/init.d/MysqL start
/etc/init.d/MysqL stopMysqL的root账户,我在连接时通常用的是localhost或127.0.0.1,公司的测试服务器上的MysqL也是localhost所以我想访问无法访问,测试暂停. 解决方法如下: 1,修改表,登录MysqL数据库,切换到MysqL数据库,使用sql语句查看"select host,user from user ;" MysqL -u root -pvmwareMysqL>use MysqL; MysqL>update user set host = '%' where user ='root'; MysqL>select host,user from user; MysqL>flush privileges; 注意:最后一句很重要,目的是使修改生效.如果没有写,则还是不能进行远程连接. 2,授权用户,你想root使用密码从任何主机连接到MysqL服务器
GRANT ALL PRIVILEGES ON *.* TO'root'@'%' IDENTIFIED BY 'admin123' WITH GRANT OPTION; flush privileges;
如果你想允许用户root从ip为192.168.1.104的主机连接到MysqL服务器
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.104' IDENTIFIED BY 'admin123' WITH GRANT OPTION; flush privileges;