LNMP服务器配置(mysql)

来源:互联网 发布:数据科学中的r语言 编辑:程序博客网 时间:2024/05/16 11:24

下载地址: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/data2016-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 pages2016-01-06 14:58:36 25960 [Note] InnoDB: The InnoDB memory heap is disabled2016-01-06 14:58:36 25960 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2016-01-06 14:58:36 25960 [Note] InnoDB: Memory barrier is not used2016-01-06 14:58:36 25960 [Note] InnoDB: Compressed tables use zlib 1.2.32016-01-06 14:58:36 25960 [Note] InnoDB: Using Linux native AIO2016-01-06 14:58:36 25960 [Note] InnoDB: Using CPU crc32 instructions2016-01-06 14:58:36 25960 [Note] InnoDB: Initializing buffer pool, size = 128.0M2016-01-06 14:58:37 25960 [Note] InnoDB: Completed initialization of buffer pool2016-01-06 14:58:37 25960 [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode2016-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: InnoDB2016-01-06 14:58:37 25960 [ERROR] Aborting2016-01-06 14:58:37 25960 [Note] Binlog end2016-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 copysupport-files/mysql.server to the right place for your systemPLEASE 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_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default.  This isstrongly 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.plPlease report any problems at http://bugs.mysql.com/The latest information about MySQL is available on the web at  http://www.mysql.comSupport MySQL by buying support/licenses at http://shop.mysql.comWARNING: 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 systemThis file will be read by default by the MySQL serverIf 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-serversudo apt-get --purge remove mysql-clientsudo apt-get --purge remove mysql-commonsudo apt-get autoremovesudo apt-get autocleansudo rm -rf /etc/mysqlsudo rm -rf /var/lib/mysql#检查which mysql #emptywhereis mysql #emptymysql --verson #mysql is not installed

重新安装

sudo apt-get updatesudo apt-get install mysql-serversudo apt-get install mysql-clientsudo apt-get install libmysqlclient-dev

安装成功

ps aux | grep mysql

这里写图片描述

登录

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

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

deb http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiversedeb http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiversedeb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiversedeb http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiversedeb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiversedeb-src http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiversedeb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiversedeb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiversedeb-src http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiversedeb-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

0 0
原创粉丝点击