LNMP服务器配置(mysql)

下载地址:http://dev.mysql.com/downloads/mysql/
select platform: Source Code
Generic Linux (Architecture Independent), Compressed TAR Archive
(mysql-5.6.28.tar.gz)

安装mysql

$sudo tar -zxvf mysql-5.6.28.tar.gz
$cd mysql-5.6.28.tar.gz
$sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/var/mysql/data
$sudo make
$sudo make install

配置mysql

//进入mysql的安装目录 /usr/local/mysql
//创建用户组和用户
$sudo groupadd mysql
$sudo useradd -g mysql mysql
//创建pid文件
//$sudo touch mysql.pid
//设置mysql安装目录权限
$sudo chown -R mysal:mysql ./  // “./”为mysql的安装路径
//复制配置文件
$sudo cp support-files/my-default.cnf /etc/my.cnf
$sudo chown mysql:mysql /etc/my.cnf
//修改配置文件
$sudo vi /etc/my.cnf

[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
[mysqld]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/mysql.pid

//初始化mysql
$sudo scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/

启动mysql

//法一 直接启动
$sudo bin/mysqld_safe &
//法二 
$cd /usr/local/mysql/
$cp support-files/mysql.server /etc/init.d/mysql

error:

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

查看错误日志

160106 14:58:36 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2016-01-06 14:58:36 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-06 14:58:36 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.28) starting as process 25960 ...
2016-01-06 14:58:36 25960 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/mysql/bin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied)
2016-01-06 14:58:36 25960 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2016-01-06 14:58:36 25960 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-06 14:58:36 25960 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-06 14:58:36 25960 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-06 14:58:36 25960 [Note] InnoDB: Memory barrier is not used
2016-01-06 14:58:36 25960 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-06 14:58:36 25960 [Note] InnoDB: Using Linux native AIO
2016-01-06 14:58:36 25960 [Note] InnoDB: Using CPU crc32 instructions
2016-01-06 14:58:36 25960 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-06 14:58:37 25960 [Note] InnoDB: Completed initialization of buffer pool
2016-01-06 14:58:37 25960 [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode
2016-01-06 14:58:37 25960 [ERROR] InnoDB: The system tablespace must be writable!
2016-01-06 14:58:37 25960 [ERROR] Plugin 'InnoDB' init function returned error.
2016-01-06 14:58:37 25960 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-01-06 14:58:37 25960 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-01-06 14:58:37 25960 [ERROR] Aborting

2016-01-06 14:58:37 25960 [Note] Binlog end
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'partition'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'ARCHIVE'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_METRICS'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_CMPMEM'
2016-01-06 14:58:37 25960 [Note] Shutting down plugin 'INNODB_CMP_RESET'

tips:重新初始化,修改data目录下所有文件权限为777

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql/bin/mysqladmin -u root -h HY password 'new-password'

Alternatively you can run:

  /usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /usr/local/mysql/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/local/mysql/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

重新启动 成功
启动mysql成功


未知原因 mysql启动不成功
重新安装,需要在安装前彻底清除mysql

sudo apt-get --purge remove mysql-server
sudo apt-get --purge remove mysql-client
sudo apt-get --purge remove mysql-common
sudo apt-get autoremove
sudo apt-get autoclean

sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql

#检查
which mysql #empty
whereis mysql #empty
mysql --verson #mysql is not installed

重新安装

sudo apt-get update
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev

安装成功

ps aux | grep mysql

这里写图片描述

登录

#用户名:root 密码:123456
mysql -uroot -p123456

环境不同可能会出现不一样的问题
有很大程度是因为apt源的问题导致的:
下面是我的源

deb http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse

注意系统更新要勾选
这里写图片描述
这里写图片描述

这样可以解决如下问题

有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是
因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件
包尚未被创建或是它们已被从新到(Incoming)目录移出。
下列信息可能会对解决问题有所帮助:

下列软件包有未满足的依赖关系:
 libc6-i386 : 依赖: libc6 (= 2.15-0ubuntu10.13) 但是 2.19-0ubuntu6.6 正要被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。

error

 cmake/readline.cmake:127 (FIND_CURSES)
 cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT)
 CMakeLists.txt:257 (MYSQL_CHECK_READLINE) 

tips:
删除所有的CMakeLists.txt文件,重新运行cmake

find / -name CMakeCache.txt

依次删除查找结果,重新cmake

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REAdMe.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REAdMe.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READme.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 、 1资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READmE.文件(md如有),本项目仅用作交流学习参考,请切勿用于商业用途。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值