|
錯(cuò)誤如圖:
錯(cuò)誤原因是:因?yàn)閚et start +服務(wù)名,啟動(dòng)的是win下注冊(cè)的服務(wù)。此時(shí),系統(tǒng)中并沒(méi)有注冊(cè)mysql到服務(wù)中。即當(dāng)前路徑下沒(méi)有mysql服務(wù)。
解決辦法:1. 來(lái)到MySQL的安裝路徑下bin 2. 在命令行中輸入mysqld --install(成功:出現(xiàn)Service successfully install代表你已經(jīng)安裝成功,)
如果不成功,出現(xiàn)Install/Remove of the Service Denied!,則需要用管理員的身份運(yùn)行DOS窗口,這樣就可以成功了
3. 執(zhí)行 net start mysql出現(xiàn): 刪除mysql下的data文件,重新執(zhí)行 mysqld --initialize (初始化data文件)就可以在當(dāng)前路徑下生成data文件夾,再執(zhí)行net start mysql 就可以啟動(dòng)mysql 應(yīng)用實(shí)例:python用pymysql鏈接mysql數(shù)據(jù)庫(kù) import pymysql import sys try: conn=pymysql.connect(host='localhost',user='root',passwd='',db='test1',port=3306,charset='utf8') except: print('打開(kāi)數(shù)據(jù)庫(kù)連接出錯(cuò),請(qǐng)檢查') 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('表在建立過(guò)程出錯(cuò)') conn.close() 運(yùn)行程序時(shí)先在mysql命令行窗口實(shí)現(xiàn)數(shù)據(jù)庫(kù)(test1)的創(chuàng)建: create database test1;
具體mysql數(shù)據(jù)庫(kù)使用方法地址:https://www.360kuai.com/pc/93bf1e5f5201b0635?cota=4&tj_url=xz&sign=360_57c3bbd1&refer_scene=so_1
本文參考鏈接:https://blog.csdn.net/ermaner666/article/details/79096939
|
|
|
來(lái)自: 筱肆 > 《網(wǎng)文收藏》