@@ -74,6 +74,7 @@ function installMac() {
7474 }
7575 // set path
7676 addToPath ( bin ) ;
77+ return bin ;
7778}
7879
7980function installWindwos ( ) {
@@ -84,6 +85,7 @@ function installWindwos() {
8485 '5.6' : '5.6.50'
8586 } ;
8687 installDir = "C:\\Program Files\\MySQL" ;
88+ bin = `C:\\Program Files\\MySQL\\MySQL Server ${ mysqlVersion } \\bin` ;
8789 if ( ! fs . existsSync ( installDir ) ) {
8890 const fullVersion = versionMap [ mysqlVersion ] ;
8991 useTmpDir ( ) ;
@@ -93,14 +95,16 @@ function installWindwos() {
9395 fs . renameSync ( `mysql-${ fullVersion } -winx64` , `C:\\Program Files\\MySQL\\MySQL Server ${ mysqlVersion } ` ) ;
9496
9597 // start
96- bin = `C:\\Program Files\\MySQL\\MySQL Server ${ mysqlVersion } \\bin` ;
9798 if ( mysqlVersion != '5.6' ) {
9899 run ( `"${ bin } \\mysqld" --initialize-insecure` ) ;
99100 }
100101 run ( `"${ bin } \\mysqld" --install` ) ;
101102 run ( `net start MySQL` ) ;
102-
103103 addToPath ( bin ) ;
104+ // create windows only user odbc
105+ run ( `"${ bin } \\mysql" -u root -e "CREATE USER 'ODBC'@'localhost' IDENTIFIED BY ''"` ) ;
106+ run ( `"${ bin } \\mysql" -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'ODBC'@'localhost'"` ) ;
107+ run ( `"${ bin } \\mysql" -u root -e "FLUSH PRIVILEGES"` ) ;
104108 }
105109
106110 run ( `"${ bin } \\mysql" -u root -e "SELECT VERSION()"` ) ;
@@ -111,6 +115,7 @@ function installWindwos() {
111115 run ( `"${ bin } \\mysql" -u root -e "GRANT ALL PRIVILEGES ON *.* TO '${ username } '@'localhost'"` ) ;
112116 run ( `"${ bin } \\mysql" -u root -e "FLUSH PRIVILEGES"` ) ;
113117 }
118+ return bin ;
114119}
115120
116121function installLinux ( ) {
@@ -143,7 +148,11 @@ function installLinux() {
143148 run ( 'sudo systemctl start mysql' ) ;
144149
145150 // remove root password
146- run ( `sudo mysqladmin -proot password ''` ) ;
151+ try {
152+ run ( `sudo mysqladmin -proot password ''` ) ;
153+ } catch ( error ) {
154+ console . log ( "error on remove password: " , error ) ;
155+ }
147156
148157 // add user
149158 if ( username && username !== "" ) {
@@ -152,11 +161,12 @@ function installLinux() {
152161 run ( `sudo mysql -e "FLUSH PRIVILEGES"` ) ;
153162 }
154163 bin = `/usr/bin` ;
164+ return bin ;
155165}
156166
157167
158168if ( process . platform == 'darwin' ) {
159- installMac ( ) ;
169+ bin = installMac ( ) ;
160170} else if ( process . platform == 'win32' ) {
161171 bin = installWindwos ( ) ;
162172} else if ( process . platform == 'linux' ) {
@@ -166,5 +176,10 @@ if (process.platform == 'darwin') {
166176}
167177
168178if ( database ) {
169- runSafe ( path . join ( bin , 'mysqladmin' ) , 'create' , database ) ;
179+ try {
180+ run ( path . join ( bin , 'mysqladmin' ) , ' -u root create' , database ) ;
181+ } catch ( error ) {
182+ console . log ( "error on create database: " , error ) ;
183+ }
184+
170185}
0 commit comments