php7+nginx下安装mysql5.7出现的一些问题及解决/以及一些mysql常用方法

一、无法启动mysql

问题描述:

输入net start mysql 

启动mysql (或打开windows服务手动启动mysql),在cmd里启动发现没法启动


解决:

    1、查看my.ini文件是否放在bin目录下

关于my.ini:

http://www.cnblogs.com/lmh2072005/p/5656392.html

    2、网上搜索了下发现是5.7版本才有这个问题,要在bin目录下手动初始化data目录

cd到bin目录下先初始化。

cmd命令框到bin目录下输入: mysqld --initialize-insecure自动生成无密码的root用户


最后:初始化后再运行net start mysql 成功启动mysql 。


二、登陆问题

设置密码后,cmd在bin目录下输入:

mysql -uroot -p回车即输入密码即可

mysql -utest -p报错


三、PHP连接MySQL报错:Fatal error: Call to undefined function mysql_connect()之解决方法

问题描述:

<?php
$host='localhost';
$user_name='root';
$password='pengzai';

$conn=mysqli_connect($host,$user_name,$password);
if (!$conn)
{
    die('数据库连接失败:'.mysql_error());
}
echo '数据库连接成功!';

if (mysqli_close($conn))
{
    echo '<br/>...<br/>';
    echo '到数据库的连接已经成功关闭';
}?>

运行后报错,检查nginx成功运行,php7其他文件成功运行。

思考:查看报错信息发现是没有找到”mysql_connection”函数,其原因似乎是没有”php_mysql.dll”,但是怎么会没有这个dll呢。

查找网络有关信息,发现需要对

;extension=php_mysql.dll 

进行操作,但这个已经被php7删除。

解决:在php.ini中找到

;extension=mysqli

将引号“;”删除,及可正常运行。


四、一些常用的mysql指令(注意末尾有没有分号)

启动MySQL:net start mysql

停止mysql: net stop mysql

登陆MySQL: mysql -uroot -p

修改MySQL密码:

        1)、mysql -uroot -p

         2)、update mysql.user set authentication_string=password('你想输入的密码') where user='root' and Host ='localhost';

         3)、flush privileges;

查看数据表: show databases;

推出MySQL: q\;

其他命令:

List of all MySQL commands:
Note that all text commands must be first on line and end with ';' (要以“;”结尾)
?  (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
notee (\t) Don't write into outfile.
print (\p) Print current command .
prompt (\R) Change your mysql prompt.
 
 
quit (\q) Quit mysql.
 
rehash (\ #) Rebuild completion hash.
source (\.) Execute an SQL script file . Takes a file name as an argument.
status (\s) Get status information from the server.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
resetconnection(\x) Clean session context.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值