cmd中输入net start mysql 提示:服务名无效或者MySQL正在启动 MySQL无法启动
时间:2022-03-15 15:57
错误如图:
如果不成功,出现Install/Remove of the Service Denied!,则需要用管理员的身份运行DOS窗口,这样就可以成功了
3. 执行 net start mysql出现:
删除mysql下的data文件,重新执行 mysqld --initialize (初始化data文件)就可以在当前路径下生成data文件夹,再执行net start mysql 就可以启动mysql
应用实例:python用pymysql链接mysql数据库
import pymysql import sys try: conn=pymysql.connect(host=‘localhost‘,user=‘root‘,passwd=‘‘,db=‘test1‘,port=3306,charset=‘utf8‘) except: print(‘打开数据库连接出错,请检查‘) conn.close() sys.exit() cur=conn.cursor() sql=‘create table if not exists T_fish (‘ ‘date1 char(12) not null,‘ ‘name char(12) not null,‘ ‘nums int not null,‘ ‘price int not null,‘ ‘sExplain varchar(200));‘ try: cur.execute(sql) conn.commit() print(‘表可以使用‘) except: print(‘表在建立过程出错‘) conn.close()
运行程序时先在mysql命令行窗口实现数据库(test1)的创建:
create database test1;
具体mysql数据库使用方法地址:https://www.360kuai.com/pc/93bf1e5f5201b0635?cota=4&tj_url=xz&sign=360_57c3bbd1&refer_scene=so_1
本文参考链接: