在Ubuntu上安装MySQL 5.6

我需要在我的ubuntu机器上安装mysql 5.6,因为开发的原因(最新版本包含我需要合并到一些web项目中的function)。 但是我有一些问题。 我一直在关注这个教程,它不是5.6版本的特定版本,但是我想这个教程大概是一样的: http : //www.ovaistariq.net/490/a-step-by-step-guide-to-upgrading-到MySQL-5-5 /

我不确定是否正确设置了我的/etc/my.cnf文件。 这是我有什么:

# Example MySQL config file for large systems. # # This is for a large system with memory = 512M where the system runs mainly # MySQL. # # MySQL programs look for option files in a set of # locations which depend on the deployment platform. # You can copy this option file to one of those # locations. For information about these locations, see: # http://dev.mysql.com/doc/mysql/en/option-files.html # # In this file, you can use all long options that a program supports. # If you want to know which options a program supports, run the program # with the "--help" option. # The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /var/run/mysqld/mysqld.sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /var/run/mysqld/mysqld.sock skip-external-locking key_buffer_size = 256M max_allowed_packet = 1M table_open_cache = 256 sort_buffer_size = 1M read_buffer_size = 1M read_rnd_buffer_size = 4M myisam_sort_buffer_size = 64M thread_cache_size = 8 query_cache_size= 16M pid_file = /usr/local/mysql/data/dev.pid basedir = /usr/local/mysql datadir = /usr/local/mysql/data tmpdir = /tmp log_error = /var/log/mysql/error.log user = mysql # Try number of CPU's*2 for thread_concurrency thread_concurrency = 8 # Don't listen on a TCP/IP port at all. This can be a security enhancement, # if all processes that need to connect to mysqld run on the same host. # All interaction with mysqld must be made via Unix sockets or named pipes. # Note that using this option without enabling named pipes on Windows # (via the "enable-named-pipe" option) will render mysqld useless! # #skip-networking # Replication Master Server (default) # binary logging is required for replication log-bin=mysql-bin # binary logging format - mixed recommended binlog_format=mixed # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted server-id = 1 # Replication Slave (comment out master section to use this) # # To configure this host as a replication slave, you can choose between # two methods : # # 1) Use the CHANGE MASTER TO command (fully described in our manual) - # the syntax is: # # CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>, # MASTER_USER=<user>, MASTER_PASSWORD=<password> ; # # where you replace <host>, <user>, <password> by quoted strings and # <port> by the master's port number (3306 by default). # # Example: # # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, # MASTER_USER='joe', MASTER_PASSWORD='secret'; # # OR # # 2) Set the variables below. However, in case you choose this method, then # start replication for the first time (even unsuccessfully, for example # if you mistyped the password in master-password and the slave fails to # connect), the slave will create a master.info file, and any later # change in this file to the variables' values below will be ignored and # overridden by the content of the master.info file, unless you shutdown # the slave server, delete master.info and restart the slaver server. # For that reason, you may want to leave the lines below untouched # (commented) and instead use CHANGE MASTER TO (see above) # # required unique id between 2 and 2^32 - 1 # (and different from the master) # defaults to 2 if master-host is set # but will not function as a slave if omitted #server-id = 2 # # The replication master for this slave - required #master-host = <hostname> # # The username the slave will use for authentication when connecting # to the master - required #master-user = <username> # # The password the slave will authenticate with when connecting to # the master - required #master-password = <password> # # The port the master is listening on. # optional - defaults to 3306 #master-port = <port> # # binary logging - not required for slaves, but recommended #log-bin=mysql-bin # Uncomment the following if you are using InnoDB tables #innodb_data_home_dir = /usr/local/mysql/data #innodb_data_file_path = ibdata1:10M:autoextend #innodb_log_group_home_dir = /usr/local/mysql/data # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 256M #innodb_additional_mem_pool_size = 20M # Set .._log_file_size to 25 % of buffer pool size #innodb_log_file_size = 64M #innodb_log_buffer_size = 8M #innodb_flush_log_at_trx_commit = 1 #innodb_lock_wait_timeout = 50 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates [myisamchk] key_buffer_size = 128M sort_buffer_size = 128M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout 

当我尝试跑步

 mysqld --skip-grant-tables --user=mysql 

我得到这个错误:

 The program 'mysqld' can be found in the following packages: * mysql-server-core-5.1 * mysql-cluster-server-5.1 Try: sudo apt-get install <selected package> 

当我尝试停止服务器,我得到这个:

 * MySQL server PID file could not be found! 

当我尝试开始时:

 Starting MySQL .. * The server quit without updating PID file (/usr/local/mysql/data/dev.pid). 

我假设我没有正确编辑my.cnf文件,但我完全失去了。 否则,我完全按照说明进行操作,并确保以前的mysql 5.1版本完全从系统中删除。

对于mysqld错误,您可能需要确保二进制文件位于$ PATH中。 尝试检查使用which mysqld

如果它不在你的path上,你应该把它添加到你的configuration文件(如果你使用bash,这可能是~/.bash_profile ):

 export PATH=/path/to/mysql/bin:$PATH 

至于PID错误,你可能会检查/var/log/mysql/error.log看看它是否给你提示什么是错误的,但我有一种感觉,可能是MySQL服务器正在运行的用户没有权限写入PID文件,所以请确保它是由mysql用户(或您的发行版的等价物)拥有。

这个问题听起来像你正在使用错误的PATHvariables关于你的MySQL安装。 也许尝试使用你的mysqld-binary的完整path。

我还写了一篇关于如何升级Ubuntu 12.04提供的mysql的文章。 看看http://www.peterchen.net/2013/02/20/en-how-to-install-mysql-5-6-on-ubuntu-12-04-precise/ 。 希望这将帮助你,因为它涵盖了MySQL 5.6而不是旧的MySQL 5.5。

我不喜欢自己的MySQL服务器pipe理超级英雄,但我认为@bhamby是正确的。 似乎你有某种版本的MySQL的某种部分安装,以某种方式打破了以前的版本,你正在运行。

另外值得注意的是: http : //dev.mysql.com/doc/refman/5.6/en/upgrading.html

MySQLbuild议您在主要发行版本之间“逐步更新”:例如从MySQL 5.1到5.5,从5.5到5.6,从5.6到5.7(等等)?

如果从全新安装开始并且没有启动或移植到另一个预先存在的数据库,则这不是必需条件,显然,只要解决了问题,似乎与您正在尝试相似从5.1跳到5.6,而不是先跳到5.5。

你的my.cnf文件看起来不是太疯狂或什么,但是你的当前数据和日志文件可能有问题需要清除。 我通常先停止MySQL服务器,然后在升级或更改日志文件大小时删除它们。

我相信这些通常在Ubuntu的“/ var / lib / mysql /”中(但不要在此引用我):

ibdata1中
ib_logfile0
ib_logfile1

经过几个小时的摆弄(还有一些图像恢复),我发现了一个非常简单的分步过程,用于在运行Ubuntu 14.03的DO云托pipe虚拟机上从MySQL 5.5升级到5.6,这对我的本地VirtualBox虚拟机运行15.04和15.10。

http://www.justinmerrill.com/step-by-step-for-upgrading-mysql-5-5-to-5-6-for-linux-ubuntu-14/computers/web-hosting/

我遵循这个指南,为那些正在从事新的Ubuntu 14或15安装工作的人们提供一个超级简单的“只需复制/粘贴CLI命令”指南,这个工具通常附带有MySQL 5.5的“开箱即用”function。 升级到MySQL 5.7的过程非常相似,但更新APT存储库MySQL默认使用MySQL 5.7,与以前的版本稍有不同。 我希望这可以帮助任何有类似问题的人升级MySQL版本。