BashOnWindow安装mysql
1、下载mysql 服务器和客户端
sudo apt-get install mysql-server mysql-client
其中过程会让输入用户名和密码
2、启动mysql服务
sudo service mysql start
在启动服务的时候,老是出现启动失败
* Starting MySQL database server mysqld [fail]
进入数据库时出现,连接有问题
mysql -uroot -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
网上对于这个问题的答案层出不穷,在这里学会了看服务日志,error.log
zhaopei@DESKTOP-4SBBGG9:~$ cd /var/log/mysql/
2017-07-20T08:28:59.628936Z mysqld_safe Logging to '/var/log/mysql/error.log'. 2017-07-20T08:29:00.523171Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 2017-07-20T08:29:00.849139Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000) 2017-07-20T08:29:00.849668Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000) 2017-07-20T08:29:01.374628Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-07-20T08:29:01.445353Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.18-0ubuntu0.16.04.1) starting as process 424 ... 2017-07-20T08:29:03.377758Z 0 [Note] InnoDB: PUNCH HOLE support available 2017-07-20T08:29:03.377869Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2017-07-20T08:29:03.377913Z 0 [Note] InnoDB: Uses event mutexes 2017-07-20T08:29:03.377955Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2017-07-20T08:29:03.377990Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8 2017-07-20T08:29:03.378022Z 0 [Note] InnoDB: Using Linux native AIO 2017-07-20T08:29:03.843214Z 0 [Note] InnoDB: Number of pools: 1 2017-07-20T08:29:04.209355Z 0 [Note] InnoDB: Using CPU crc32 instructions 2017-07-20T08:29:04.319753Z 0 [ERROR] InnoDB: Linux Native AIO interface is not supported on this platform. Please check your OS documentation and install appropriate binary of InnoDB. 2017-07-20T08:29:04.321070Z 0 [Note] InnoDB: You can disable Linux Native AIO by setting innodb_use_native_aio = 0 in my.cnf 2017-07-20T08:29:04.321134Z 0 [Warning] InnoDB: Linux Native AIO disabled. 2017-07-20T08:29:04.362427Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2017-07-20T08:29:04.509850Z 0 [Note] InnoDB: Completed initialization of buffer pool 2017-07-20T08:29:04.722843Z 0 [Note] InnoDB: page_cleaner coordinator priority: -20 2017-07-20T08:29:04.916626Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2017-07-20T08:29:06.327288Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2017-07-20T08:29:06.354940Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2017-07-20T08:29:06.620314Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2017-07-20T08:29:06.634545Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2017-07-20T08:29:06.636112Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2017-07-20T08:29:06.647838Z 0 [Note] InnoDB: Waiting for purge to start 2017-07-20T08:29:06.720627Z 0 [Note] InnoDB: Waiting for purge to start 2017-07-20T08:29:06.786791Z 0 [Note] InnoDB: 5.7.18 started; log sequence number 2536366 2017-07-20T08:29:06.792654Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2017-07-20T08:29:07.079595Z 0 [Note] Plugin 'FEDERATED' is disabled. 2017-07-20T08:29:08.155498Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170720 16:29:08 2017-07-20T08:29:08.589818Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key 2017-07-20T08:29:08.590045Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306 2017-07-20T08:29:08.590235Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1'; 2017-07-20T08:29:08.590341Z 0 [Note] Server socket created on IP: '127.0.0.1'. 2017-07-20T08:29:08.590433Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Permission denied 2017-07-20T08:29:08.590489Z 0 [ERROR] Do you already have another mysqld server running on port: 3306 ? 2017-07-20T08:29:08.590549Z 0 [ERROR] Aborting 2017-07-20T08:29:08.590607Z 0 [Note] Binlog end 2017-07-20T08:29:08.605607Z 0 [Note] Shutting down plugin 'ngram' 2017-07-20T08:29:08.605739Z 0 [Note] Shutting down plugin 'ARCHIVE' 2017-07-20T08:29:08.605780Z 0 [Note] Shutting down plugin 'BLACKHOLE' 2017-07-20T08:29:08.619022Z 0 [Note] Shutting down plugin 'partition' 2017-07-20T08:29:08.619153Z 0 [Note] Shutting down plugin 'MyISAM' 2017-07-20T08:29:08.620655Z 0 [Note] Shutting down plugin 'MRG_MYISAM' 2017-07-20T08:29:08.620778Z 0 [Note] Shutting down plugin 'CSV' 2017-07-20T08:29:08.620846Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA' 2017-07-20T08:29:08.620942Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL' 2017-07-20T08:29:08.620998Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES' 2017-07-20T08:29:08.621047Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES' 2017-07-20T08:29:08.621096Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS' 2017-07-20T08:29:08.621141Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN' 2017-07-20T08:29:08.621186Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS' 2017-07-20T08:29:08.621227Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS' 2017-07-20T08:29:08.621272Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES' 2017-07-20T08:29:08.621315Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS' 2017-07-20T08:29:08.621355Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES' 2017-07-20T08:29:08.621402Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE' 2017-07-20T08:29:08.621448Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE' 2017-07-20T08:29:08.621494Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG' 2017-07-20T08:29:08.621542Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED' 2017-07-20T08:29:08.621588Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED' 2017-07-20T08:29:08.621635Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD' 2017-07-20T08:29:08.621684Z 0 [Note] Shutting down plugin 'INNODB_METRICS' 2017-07-20T08:29:08.621730Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO' 2017-07-20T08:29:08.621777Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS' 2017-07-20T08:29:08.621826Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU' 2017-07-20T08:29:08.621871Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE' 2017-07-20T08:29:08.621916Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET' 2017-07-20T08:29:08.621960Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX' 2017-07-20T08:29:08.622005Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET' 2017-07-20T08:29:08.622048Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM' 2017-07-20T08:29:08.622084Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET' 2017-07-20T08:29:08.622128Z 0 [Note] Shutting down plugin 'INNODB_CMP' 2017-07-20T08:29:08.622172Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS' 2017-07-20T08:29:08.622215Z 0 [Note] Shutting down plugin 'INNODB_LOCKS' 2017-07-20T08:29:08.622259Z 0 [Note] Shutting down plugin 'INNODB_TRX' 2017-07-20T08:29:08.622303Z 0 [Note] Shutting down plugin 'InnoDB' 2017-07-20T08:29:08.644637Z 0 [Note] InnoDB: FTS optimize thread exiting. 2017-07-20T08:29:08.645453Z 0 [Note] InnoDB: Starting shutdown... 2017-07-20T08:29:08.745799Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool 2017-07-20T08:29:08.748425Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 170720 16:29:08 2017-07-20T08:29:09.428215Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2536394 2017-07-20T08:29:09.430927Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 2017-07-20T08:29:09.431083Z 0 [Note] Shutting down plugin 'MEMORY' 2017-07-20T08:29:09.431244Z 0 [Note] Shutting down plugin 'sha256_password' 2017-07-20T08:29:09.431298Z 0 [Note] Shutting down plugin 'mysql_native_password' 2017-07-20T08:29:09.431476Z 0 [Note] Shutting down plugin 'binlog' 2017-07-20T08:29:09.431935Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
复制第一条error信息,gg发现一条信息跟我的日志文件问题一模一样,https://github.com/Microsoft/BashOnWindows/issues/2113
修改方式就是 更改mysql的端口
查看mysql的配置文件:
$ cat /etc/mysql/mysql.conf.d/mysqld.cnf
更改端口3306位8060,保存发现readonly, 没权限更改
只需要在编辑的时候,加个权限即可, sudo
至此,mysql服务可以启动
分析:因为在win里已经安装了mysql,开机时自动打开3306端口。